lib/nanoc3/base/compiler_dsl.rb in nanoc3-3.0.1 vs lib/nanoc3/base/compiler_dsl.rb in nanoc3-3.0.2
- old
+ new
@@ -97,10 +97,15 @@
# Converts the given identifier, which can contain the '*' wildcard, to a regex.
# For example, 'foo/*/bar' is transformed into /^foo\/(.*?)\/bar$/.
def identifier_to_regex(identifier)
if identifier.is_a? String
- /^#{identifier.cleaned_identifier.gsub('*', '(.*?)')}?$/
+ # Add leading/trailing slashes if necessary
+ new_identifier = identifier.dup
+ new_identifier[/^/] = '/' if identifier[0,1] != '/'
+ new_identifier[/$/] = '/' unless [ '*', '/' ].include?(identifier[-1,1])
+
+ /^#{new_identifier.gsub('*', '(.*?)')}$/
else
identifier
end
end