- my @mapitems = ();
- foreach my $page (keys %links) {
- if (pagespec_match($page, $params{pages}, $params{page})) {
- push @mapitems, $page;
+ my %mapitems;
+ foreach my $page (keys %pagesources) {
+ if (pagespec_match($page, $params{pages}, location => $params{page})) {
+ $mapitems{$page}=1;
+
+ # Check for a common prefix.
+ if (! defined $common_prefix) {
+ $common_prefix=$page;
+ }
+ elsif (length $common_prefix &&
+ $page !~ /^\Q$common_prefix\E(\/|$)/) {
+ my @a=split(/\//, $page);
+ my @b=split(/\//, $common_prefix);
+ $common_prefix="";
+ while (@a && @b && $a[0] eq $b[0]) {
+ if (length $common_prefix) {
+ $common_prefix.="/";
+ }
+ $common_prefix.=shift(@a);
+ shift @b;
+ }
+ }