1
0
mirror of https://github.com/wting/autojump synced 2024-09-28 22:10:45 +00:00

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

This commit is contained in:
york 2021-01-02 21:07:11 +08:00
parent 06e082c918
commit b597d00e5c

View File

@ -75,7 +75,7 @@ def match_consecutive(needles, haystack, ignore_case=False):
(path='/foo/baz', weight=10), (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_no_sep_end = regex_no_sep + '$'
regex_one_sep = regex_no_sep + os.sep + 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 regex_needle = regex_one_sep.join(imap(re.escape, needles)) + regex_no_sep_end