}
my %re_map = ( '*' => '[^/]*?', '?' => '[^/]',
+ '/**' => '/.*', '**/' => '.*/', '/**/' => '/.*?',
'[' => '[', ']' => ']', ',' => ',' );
sub glob2re ($) {
if ($re =~ s!\A([a-z0-9\+]+://\[[a-f0-9\:]+\](?::[0-9]+)?/)!!i) {
$schema_host_port = quotemeta $1; # "http://[::1]:1234"
}
- my $changes = ($re =~ s!(.)!
+ my $changes = ($re =~ s!(/\*\*/|\A\*\*/|/\*\*\z|.)!
$re_map{$p eq '\\' ? '' : do {
if ($1 eq '[') { ++$in_bracket }
elsif ($1 eq ']') { --$in_bracket }
is_deeply($glob2re->('{[a-z],9,}'), '([a-z]|9|)' , 'brace with range');
is_deeply($glob2re->('\\{a,b\\}'), undef, 'escaped brace');
is_deeply($glob2re->('\\\\{a,b}'), '\\\\\\\\(a|b)', 'fake escape brace');
+is_deeply($glob2re->('**/foo'), '.*/foo', 'double asterisk start');
+is_deeply($glob2re->('foo/**'), 'foo/.*', 'double asterisk end');
+my $re = $glob2re->('a/**/b');
+is_deeply($re, 'a/.*?b', 'double asterisk middle');
+like($_, qr!$re!, "a/**/b matches $_") for ('a/b', 'a/c/b', 'a/c/a/b');
done_testing();