18 $uri->scheme($scheme);
20 if (defined $username) {
21 $uri->authority( "$username:$password" );
25 $uri->port($port) if $port;
27 elsif (defined $relative && $relative)
29 # this is a local link and conversion from absolute to relative
32 # original component path (e. g. 'htdocs/news/index.html')
33 my @caller_path = File::Spec->splitdir($m->request_comp()->path());
35 # remove target directory portion
36 # e. g. ('news', 'index.html')
40 # remove filename portion
44 my $caller_dir = File::Spec->catfile("", @caller_path);
45 $caller_dir = "/" if ($caller_dir eq "");
47 $path = File::Spec->abs2rel($path, $caller_dir);
49 $path = "." if ($path eq "");
52 # Sometimes we may want to path in a query string
53 # but the URI module will escape the question mark.
56 if ( $path =~ s/\?(.*)$// ) {
62 # If there was a query string, we integrate it into the query
65 %query = ( %query, split /[&=]/, $q );
68 $query{session_id} ||= $session_id;
69 $query{session_id} ||= $context->{session_id} if (defined $context);
72 # $uri->query_form doesn't handle hash ref values properly
73 while ( my ( $key, $value ) = each %query ) {
74 $query{$key} = ref $value eq 'HASH' ? [ %$value ] : $value;
77 delete $query{session_id} if ($no_session or ($query{session_id} eq ''));
79 $uri->query_form(%query) if %query;
81 $uri->fragment($fragment) if $fragment;
83 <% $uri->canonical | n %>\