re.escape(os.sep) because on windows os.sep is \ and need escape

pull/618/head
york 3 years ago
parent 06e082c918
commit b597d00e5c

@ -75,7 +75,7 @@ def match_consecutive(needles, haystack, ignore_case=False):
(path='/foo/baz', weight=10),
]
"""
regex_no_sep = '[^' + os.sep + ']*'
regex_no_sep = '[^' + re.escape(os.sep) + ']*'
regex_no_sep_end = regex_no_sep + '$'
regex_one_sep = regex_no_sep + os.sep + regex_no_sep
regex_needle = regex_one_sep.join(imap(re.escape, needles)) + regex_no_sep_end

Loading…
Cancel
Save