From 4918c164e863a637445516c88fcd3efe6ae5262e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 23 Jul 2008 19:03:37 -0400 Subject: [PATCH] preserve case of subpage --- IkiWiki/Plugin/link.pm | 7 ++++--- t/renamepage.t | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/IkiWiki/Plugin/link.pm b/IkiWiki/Plugin/link.pm index e20109888..515a62bce 100644 --- a/IkiWiki/Plugin/link.pm +++ b/IkiWiki/Plugin/link.pm @@ -92,9 +92,10 @@ sub renamepage (@) { #{{{ my $link=$linktext; if (bestlink($page, $2) eq $old) { $link=$new; - if ($linktext =~ m/\/*?[A-Z]/) { - # preserve leading cap - $link=ucfirst($link); + if ($linktext =~ m/.*\/*?[A-Z]/) { + # preserve leading cap of last component + my @bits=split("/", $link); + $link=join("/", @bits[0..$#bits-1], ucfirst($bits[$#bits])); } if (index($linktext, "/") == 0) { # absolute link diff --git a/t/renamepage.t b/t/renamepage.t index b16ca3d23..ccb33d817 100755 --- a/t/renamepage.t +++ b/t/renamepage.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More tests => 14; +use Test::More tests => 15; use Encode; BEGIN { use_ok("IkiWiki"); } @@ -35,6 +35,7 @@ is(try("z", "foo" => "bar", "[[bar]]"), "[[bar]]"); # link already to new page is(try("z", "foo" => "bar", "[[foo]]"), "[[bar]]"); # basic conversion to new page name is(try("z", "foo" => "bar", "[[/foo]]"), "[[/bar]]"); # absolute link is(try("z", "foo" => "bar", "[[Foo]]"), "[[Bar]]"); # preserve case +is(try("z", "x/foo" => "x/bar", "[[x/Foo]]"), "[[x/Bar]]"); # preserve case of subpage is(try("z", "foo" => "bar", "[[/Foo]]"), "[[/Bar]]"); # preserve case w/absolute is(try("z", "foo" => "bar", "[[foo]] [[xxx]]"), "[[bar]] [[xxx]]"); # 2 links, 1 converted is(try("z", "foo" => "bar", "[[xxx|foo]]"), "[[xxx|bar]]"); # conversion w/text -- 2.39.5