test suite and partial fix for encoding issues in link renaming
[ikiwiki.git] / IkiWiki / Plugin / link.pm
index e201098884b2921ecfd9842993ddb273135fbb31..529610710064e0a99c5ae29239f9a713534762fa 100644 (file)
@@ -91,10 +91,11 @@ sub renamepage (@) { #{{{
                my $linktext=$2;
                my $link=$linktext;
                if (bestlink($page, $2) eq $old) {
-                       $link=$new;
-                       if ($linktext =~ m/\/*?[A-Z]/) {
-                               # preserve leading cap
-                               $link=ucfirst($link);
+                       $link=IkiWiki::pagetitle($new, 1);
+                       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