]> git.deb.at Git - deb/packages.git/blobdiff - lib/Packages/Template.pm
Handle broken Homepage fields more gracefully
[deb/packages.git] / lib / Packages / Template.pm
index 28d8d1ed4c84588b8dd0a2654c10350390c69ade..a3268a35f046d5141003e1d6da5b6fffd7540010 100644 (file)
@@ -38,10 +38,14 @@ sub new {
     if ($vars->{cat}) {
        $vars->{g} = sub { return Packages::I18N::Locale::g($vars->{cat}, @_) };
     }
-    $vars->{extract_host} = sub { my $uri = URI->new($_[0]);
-                                 my $host = $uri->host;
-                                 $host .= ':'.$uri->port if $uri->port != $uri->default_port;
-                                 return $host;
+    $vars->{extract_host} = sub { my $uri_str = $_[0];
+                                 my $uri = URI->new($uri_str);
+                                 if ($uri->can('host')) {
+                                     my $host = $uri->host;
+                                     $host .= ':'.$uri->port if $uri->port != $uri->default_port;
+                                     return $host;
+                                 }
+                                 return $uri_str;
                              };
     # needed to work around the limitations of the the FILTER syntax
     $vars->{html_encode} = sub { return HTML::Entities::encode_entities(@_,'<>&"') };