[Jifty-commit] jifty branch, plack-rebased, updated. 769c800f02ae49a850c4171f6a5fe69af5ce0b55

Jifty commits jifty-commit at lists.jifty.org
Sun Feb 7 07:38:23 EST 2010


The branch, plack-rebased has been updated
       via  769c800f02ae49a850c4171f6a5fe69af5ce0b55 (commit)
      from  686bc526ace9c0c23cf125aabb69e9eea0478ffa (commit)

Summary of changes:
 lib/Jifty/Web.pm |   33 ++++++++++++++-------------------
 1 files changed, 14 insertions(+), 19 deletions(-)

- Log -----------------------------------------------------------------
commit 769c800f02ae49a850c4171f6a5fe69af5ce0b55
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Sun Feb 7 20:38:07 2010 +0800

    Rework the ->url logic broken in dae6c2f

diff --git a/lib/Jifty/Web.pm b/lib/Jifty/Web.pm
index be38252..06efcb4 100644
--- a/lib/Jifty/Web.pm
+++ b/lib/Jifty/Web.pm
@@ -120,35 +120,30 @@ form the path part of the resulting URL.
 sub url {
     my $self = shift;
     my %args = (scheme => undef,
-                path => '/',
+                path => undef,
                 @_);
 
     my $uri;
 
-    $uri = Jifty->web->request->uri->clone if Jifty->web->request;
+    my $req = Jifty->web->request;
+    if ($req && $req->uri->host) {
+        $uri = $req->uri->clone;
+        $uri->path('/');
+    }
+    else {
+        $uri = URI->new(Jifty->config->framework("Web")->{BaseURL});
+        $uri->port(Jifty->config->framework("Web")->{Port});
+    }
 
-    if (!$uri) {
-      my $url  = Jifty->config->framework("Web")->{BaseURL};
-      my $port = Jifty->config->framework("Web")->{Port};
-   
-      $uri = URI->new($url);
-      $uri->port($port);
+    if (defined (my $path = $args{path})) {
+        # strip off leading '/' because ->canonical provides one
+        $path =~ s{^/}{};
+        $uri->path_query($path);
     }
 
     # https is sticky
     $uri->scheme('https') if $uri->scheme eq 'http' && Jifty->web->is_ssl;
 
-    if ( defined $args{'scheme'} ) {
-        $uri->scheme( $args{'scheme'} );
-    }
-
-    if (defined $args{path}) {
-      my $path = $args{path};
-      # strip off leading '/' because ->canonical provides one
-      $path =~ s{^/}{};
-      $uri->path_query($path);
-    }
-    
     return $uri->canonical->as_string;
 }
 

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list