Skip to content

Commit 06a9d86

Browse files
taliJunio C Hamano
authored andcommitted
gitweb: provide function to format the URL for an action link.
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]>
1 parent 19a8721 commit 06a9d86

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

gitweb/gitweb.perl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,33 @@
184184
$actions{$action}->();
185185
exit;
186186

187+
## ======================================================================
188+
## action links
189+
190+
sub href(%) {
191+
my %mapping = (
192+
action => "a",
193+
project => "p",
194+
file_name => "f",
195+
hash => "h",
196+
hash_parent => "hp",
197+
hash_base => "hb",
198+
page => "pg",
199+
searchtext => "s",
200+
);
201+
202+
my %params = @_;
203+
$params{"project"} ||= $project;
204+
205+
my $href = "$my_uri?";
206+
$href .= esc_param( join(";",
207+
map { "$mapping{$_}=$params{$_}" } keys %params
208+
) );
209+
210+
return $href;
211+
}
212+
213+
187214
## ======================================================================
188215
## validation, quoting/unquoting and escaping
189216

0 commit comments

Comments
 (0)