optimise single dot detection
Since it already looks for things starting with a dot, I was able to avoid matching against the string twice. This also fixes a minor bug; $from may not be defined. Avoid uninitialized value warnings in this case.master
parent
7d1cc3a020
commit
991d01f5b5
17
IkiWiki.pm
17
IkiWiki.pm
|
@ -2401,14 +2401,17 @@ package IkiWiki::PageSpec;
|
|||
sub derel ($$) {
|
||||
my $path=shift;
|
||||
my $from=shift;
|
||||
if ($path eq '.') {
|
||||
$path = $from;
|
||||
}
|
||||
|
||||
if ($path =~ m!^\./!) {
|
||||
$from=~s#/?[^/]+$## if defined $from;
|
||||
$path=~s#^\./##;
|
||||
$path="$from/$path" if defined $from && length $from;
|
||||
if ($path =~ m!^\.(/|$)!) {
|
||||
if ($1) {
|
||||
$from=~s#/?[^/]+$## if defined $from;
|
||||
$path=~s#^\./##;
|
||||
$path="$from/$path" if defined $from && length $from;
|
||||
}
|
||||
else {
|
||||
$path = $from;
|
||||
$path = "" unless defined $path;
|
||||
}
|
||||
}
|
||||
|
||||
return $path;
|
||||
|
|
Loading…
Reference in New Issue