preserve case of subpage

master
Joey Hess 2008-07-23 19:03:37 -04:00
parent 8b063a24d9
commit 4918c164e8
2 changed files with 6 additions and 4 deletions

View File

@ -92,9 +92,10 @@ sub renamepage (@) { #{{{
my $link=$linktext; my $link=$linktext;
if (bestlink($page, $2) eq $old) { if (bestlink($page, $2) eq $old) {
$link=$new; $link=$new;
if ($linktext =~ m/\/*?[A-Z]/) { if ($linktext =~ m/.*\/*?[A-Z]/) {
# preserve leading cap # preserve leading cap of last component
$link=ucfirst($link); my @bits=split("/", $link);
$link=join("/", @bits[0..$#bits-1], ucfirst($bits[$#bits]));
} }
if (index($linktext, "/") == 0) { if (index($linktext, "/") == 0) {
# absolute link # absolute link

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl #!/usr/bin/perl
use warnings; use warnings;
use strict; use strict;
use Test::More tests => 14; use Test::More tests => 15;
use Encode; use Encode;
BEGIN { use_ok("IkiWiki"); } 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]]"); # basic conversion to new page name
is(try("z", "foo" => "bar", "[[/foo]]"), "[[/bar]]"); # absolute link is(try("z", "foo" => "bar", "[[/foo]]"), "[[/bar]]"); # absolute link
is(try("z", "foo" => "bar", "[[Foo]]"), "[[Bar]]"); # preserve case 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]]"), "[[/Bar]]"); # preserve case w/absolute
is(try("z", "foo" => "bar", "[[foo]] [[xxx]]"), "[[bar]] [[xxx]]"); # 2 links, 1 converted 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 is(try("z", "foo" => "bar", "[[xxx|foo]]"), "[[xxx|bar]]"); # conversion w/text