Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/github/markup/implementation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def match?(filename, language)
private

def file_ext_regexp
@file_ext_regexp ||= /\.(#{regexp})\z/
# Use regexp.source so an /i flag on this pattern applies to the
# extension itself. Interpolating a Regexp object embeds (?-mix:),
# which would keep .MD from matching /md/.
@file_ext_regexp ||= /\.(?:#{regexp.source})\z/i
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions test/coverage_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def initialize; super(/md|markdown/, []); end
assert impl.match?("README.md", nil)
# call again to cover the memoization branch in file_ext_regexp
assert impl.match?("README.markdown", nil)
assert impl.match?("README.MD", nil)
assert impl.match?("README.Markdown", nil)
refute impl.match?("README.txt", nil)
end
end
Expand Down