- my $links = $IkiWiki::links{$page} or return undef;
- foreach my $p (@$links) {
- return 1 if lc $p eq $link;
+ # relative matching
+ if ($link =~ m!^\.! && defined $from) {
+ $from=~s#/?[^/]+$##;
+ $link=~s#^\./##;
+ $link="$from/$link" if length $from;
+ }
+
+ my $links = $IkiWiki::links{$page};
+ return IkiWiki::FailReason->new("$page has no links") unless $links && @{$links};
+ my $bestlink = IkiWiki::bestlink($from, $link);
+ foreach my $p (@{$links}) {
+ if (length $bestlink) {
+ return IkiWiki::SuccessReason->new("$page links to $link")
+ if $bestlink eq IkiWiki::bestlink($page, $p);
+ }
+ else {
+ return IkiWiki::SuccessReason->new("$page links to page $p matching $link")
+ if match_glob($p, $link, %params);
+ }