From: Joey Hess <joey@kitenet.net>
Date: Fri, 28 Dec 2007 22:22:17 +0000 (-0500)
Subject: * map: Fix handling of common prefix to handle the case where it's
X-Git-Tag: 2.17~4
X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/3e784ea8a1aeb41aa181c29b499cf76ab83dc6d0?ds=inline;hp=-c

* map: Fix handling of common prefix to handle the case where it's
  in a subdirectory. Patch by Larry Clapp.
---

3e784ea8a1aeb41aa181c29b499cf76ab83dc6d0
diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm
index 5b6af1f36..581ae5011 100644
--- a/IkiWiki/Plugin/map.pm
+++ b/IkiWiki/Plugin/map.pm
@@ -37,6 +37,9 @@ sub preprocess (@) { #{{{
 				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;
 				}
diff --git a/debian/changelog b/debian/changelog
index c48d538e9..71119b3f5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,8 @@ ikiwiki (2.17) UNRELEASED; urgency=low
   * conditional: Improve regexp testing for simple uses of pagespecs
     that match only the page using the directive, adding 'included()'
     and supporting negated pagespecs and added whitespace.
+  * map: Fix handling of common prefix to handle the case where it's
+    in a subdirectory. Patch by Larry Clapp.
 
  -- Joey Hess <joeyh@debian.org>  Wed, 19 Dec 2007 16:39:07 -0500
 
diff --git a/doc/bugs/map_doesn__39__t_calculate___34__common__95__prefix__34___correctly.mdwn b/doc/bugs/map_doesn__39__t_calculate___34__common__95__prefix__34___correctly.mdwn
index 9436cbd0c..d6923605d 100644
--- a/doc/bugs/map_doesn__39__t_calculate___34__common__95__prefix__34___correctly.mdwn
+++ b/doc/bugs/map_doesn__39__t_calculate___34__common__95__prefix__34___correctly.mdwn
@@ -66,3 +66,5 @@ Note that you you don't get "blog" or "tags", and "life" and "tech" are links no
 Map tries to calculate a "common prefix" between the pagespec and the page being rendered, and then later does some substitutions using the prefix.  But the path has /'s in it and the common prefix doesn't, so it never matches correctly.  So, add the /'s.
 
 -- [[users/Larry_Clapp]]
+
+> Excellent problem description and analysis. Patch [[applied|done]] --[[Joey]]