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

Jifty commits jifty-commit at lists.jifty.org
Sun Feb 7 03:44:57 EST 2010


The branch, plack-rebased has been updated
       via  dae6c2f4d2c4ebd6e786e55b465c92e9cf32754f (commit)
      from  6f6a051060caedee02e6209cec5f07bd67518cd8 (commit)

Summary of changes:
 lib/Jifty/Web.pm |   28 ++--------------------------
 1 files changed, 2 insertions(+), 26 deletions(-)

- Log -----------------------------------------------------------------
commit dae6c2f4d2c4ebd6e786e55b465c92e9cf32754f
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Sun Feb 7 16:44:52 2010 +0800

    Simplify Jifty->web->url since we now have reliable request->uri object.

diff --git a/lib/Jifty/Web.pm b/lib/Jifty/Web.pm
index 956a92d..be38252 100644
--- a/lib/Jifty/Web.pm
+++ b/lib/Jifty/Web.pm
@@ -120,36 +120,12 @@ form the path part of the resulting URL.
 sub url {
     my $self = shift;
     my %args = (scheme => undef,
-                path => undef,
+                path => '/',
                 @_);
 
     my $uri;
 
-    # Try to get a host out of the environment, useful in remote testing.
-    # The code is a little hairy because there's no guarantee these
-    # environment variables have all the information.
-    if (Jifty->web->request && (my $http_host_env = Jifty->web->request->uri->host)) {
-        # Explicit flag needed because URI->new("noscheme") is structurally
-        # different from URI->new("http://smth"). Clunky, but works.
-        my $dirty;
-        if ($http_host_env !~ m{^http(s?)://}) {
-            $dirty++;
-            $http_host_env = (Jifty->web->is_ssl ? "https" : "http") ."://$http_host_env";
-        }
-        $uri = URI->new($http_host_env);
-        if ($dirty && Jifty->web->request && (my $req_uri_env = Jifty->web->request->request_uri)) {
-            my $req_uri = URI->new($req_uri_env);
-            $uri->scheme($req_uri->scheme) if $req_uri->can('scheme');
-            $dirty = $uri->scheme;
-        }
-        # As a last resort, peek at the BaseURL configuration setting
-        # for the scheme, which is an often-missing part.
-        if ($dirty) {
-            my $config_uri = URI->new(
-                    Jifty->config->framework("Web")->{BaseURL});
-            $uri->scheme($config_uri->scheme);
-        }
-    }
+    $uri = Jifty->web->request->uri->clone if Jifty->web->request;
 
     if (!$uri) {
       my $url  = Jifty->config->framework("Web")->{BaseURL};

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


More information about the Jifty-commit mailing list