Skip to content

Commit

Permalink
gitweb: provide function to format the URL for an action link.
Browse files Browse the repository at this point in the history
Provide a new function which can be used to generate an URL for the CGI.
This makes it possible to consolidate the URL generation in order to make
it easier to change the encoding of actions into URLs.

Signed-off-by: Martin Waitz <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
tali authored and Junio C Hamano committed Aug 16, 2006
1 parent 19a8721 commit 06a9d86
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,33 @@
$actions{$action}->();
exit;

## ======================================================================
## action links

sub href(%) {
my %mapping = (
action => "a",
project => "p",
file_name => "f",
hash => "h",
hash_parent => "hp",
hash_base => "hb",
page => "pg",
searchtext => "s",
);

my %params = @_;
$params{"project"} ||= $project;

my $href = "$my_uri?";
$href .= esc_param( join(";",
map { "$mapping{$_}=$params{$_}" } keys %params
) );

return $href;
}


## ======================================================================
## validation, quoting/unquoting and escaping

Expand Down

0 comments on commit 06a9d86

Please sign in to comment.