From e1af71c24965bc087877d424a1828ac74ba2f6a4 Mon Sep 17 00:00:00 2001 From: Hashim1999164 <64767361+Hashim1999164@users.noreply.github.com> Date: Wed, 19 Aug 2026 00:59:26 +0500 Subject: [PATCH] Match markup file extensions without regard to case. --- lib/github/markup/implementation.rb | 5 ++++- test/coverage_test.rb | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/github/markup/implementation.rb b/lib/github/markup/implementation.rb index 458ab0d8..5e5c4aab 100644 --- a/lib/github/markup/implementation.rb +++ b/lib/github/markup/implementation.rb @@ -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 diff --git a/test/coverage_test.rb b/test/coverage_test.rb index f5043b5d..63c27c8f 100644 --- a/test/coverage_test.rb +++ b/test/coverage_test.rb @@ -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