Skip to content

Commit c1764a0

Browse files
portability: swap RegExp.escape for lodash alternative
1 parent 239550e commit c1764a0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/components/cylc/common/filter.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ import {
2323
TaskStateNames,
2424
WaitingStateModifierNames,
2525
} from '@/model/TaskState.model'
26+
import {
27+
escapeRegExp
28+
} from 'lodash-es'
2629

2730
/* Convert a glob to a Regex.
2831
*
@@ -45,14 +48,12 @@ export function globToRegex (glob) {
4548
// prefix a space then subtract the first four characters (`\x20`)
4649
// from the result
4750
// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/escape
48-
RegExp.escape(' ' + glob.trim())
49-
.substr(4)
50-
// `*` -> `.*`
51+
escapeRegExp(glob.trim())
5152
.replace(/\\\*/, '.*')
5253
// `?` -> `.`
5354
.replace(/\\\?/, '.')
5455
// `[!X]` -> `[^X]`
55-
.replace(/\\\[\\x21([^]*)\\\]/, '[^$1]')
56+
.replace(/\\\[!([^]*)\\\]/, '[^$1]')
5657
// `[X]` -> `[X]`
5758
.replace(/\\\[([^]*)\\\]/, '[$1]')
5859
)

0 commit comments

Comments
 (0)