my $re=quotemeta(shift);
$re=~s/\\\*/.*/g;
$re=~s/\\\?/./g;
- return $re;
+ return qr/^$re$/i;
}
package IkiWiki::FailReason;
# Instead of converting the glob to a regex every time,
# cache the compiled regex to save time.
- if (!defined $glob_cache{$glob}) {
- my $re = IkiWiki::glob2re($glob);
- $glob_cache{$glob} = qr/^$re$/i;
+ my $re=$glob_cache{$glob};
+ unless (defined $re) {
+ $glob_cache{$glob} = $re = IkiWiki::glob2re($glob);
}
- if ($page=~ $glob_cache{$glob}) {
+ if ($page =~ $re) {
if (! IkiWiki::isinternal($page) || $params{internal}) {
return IkiWiki::SuccessReason->new("$glob matches $page");
}
return IkiWiki::ErrorReason->new("no user specified");
}
- if (defined $params{user} && $params{user}=~/^$regexp$/i) {
+ if (defined $params{user} && $params{user}=~$regexp) {
return IkiWiki::SuccessReason->new("user is $user");
}
elsif (! defined $params{user}) {