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
#!/usr/bin/perl
use warnings;
use strict;
-use Test::More tests => 14;
+use Test::More tests => 15;
use Encode;
BEGIN { use_ok("IkiWiki"); }
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