blob: 3b54f046c7bbb8d94ba27aab6efb480cfe7ff595 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# frozen_string_literal: true
module RuboCop
module PathUtil
def match_path?(pattern, path)
case pattern
when String
matched = if /[*{}]/.match?(pattern)
File.fnmatch?(pattern, path, File::FNM_PATHNAME | File::FNM_EXTGLOB)
else
pattern == path
end
matched || hidden_file_in_not_hidden_dir?(pattern, path)
when Regexp
begin
pattern.match?(path)
rescue ArgumentError => e
return false if e.message.start_with?('invalid byte sequence')
raise e
end
end
end
end
end
|