Skip to contentSkip to conversation

gitweb: Allow for multivalued parameters passed to href subroutine

PATCH New Jakub Narebski 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb: Allow for multivalued parameters passed to href subroutine

Make it possible to generate URLs with multivalued parameters in the href() subroutine, via passing reference to array of values.

Example:
href(action=>"log", extra_options=>["--no-merges", "--first-parent"])

---
 gitweb/gitweb.perl |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +7 -1
index 8a32899..498b936 100755
@@ -629,7 +629,13 @@ sub href(%) {
 	for (my $i = 0; $i < @mapping; $i += 2) {
 		my ($name, $symbol) = ($mapping[$i], $mapping[$i+1]);
 		if (defined $params{$name}) {
-			push @result, $symbol . "=" . esc_param($params{$name});
+			if (ref($params{$name}) eq "ARRAY") {
+				foreach my $par (@{$params{$name}}) {
+					push @result, $symbol . "=" . esc_param($par);
+				}
+			} else {
+				push @result, $symbol . "=" . esc_param($params{$name});
+			}
 		}
 	}
 	$href .= "?" . join(';', @result) if scalar @result;
Signature · 1 line
1.5.2.4