File tree Expand file tree Collapse file tree 1 file changed +3
-18
lines changed Expand file tree Collapse file tree 1 file changed +3
-18
lines changed Original file line number Diff line number Diff line change @@ -11,24 +11,9 @@ const BACKSLASH = '\\';
11
11
function unescapeBackslash ( raw ) {
12
12
const quote = raw . charAt ( 0 ) ;
13
13
14
- raw = raw . slice ( 1 , - 1 ) ;
15
-
16
- let result = '' ;
17
- for ( let position = 0 ; position < raw . length ; position ++ ) {
18
- const character = raw [ position ] ;
19
- if ( character === BACKSLASH ) {
20
- const nextCharacter = raw [ position + 1 ] ;
21
- if ( nextCharacter === BACKSLASH || nextCharacter === quote ) {
22
- result += nextCharacter ;
23
- position ++ ;
24
- continue ;
25
- }
26
- }
27
-
28
- result += character ;
29
- }
30
-
31
- return result ;
14
+ return raw
15
+ . slice ( 1 , - 1 )
16
+ . replaceAll ( new RegExp ( String . raw `\\(?<escapedCharacter>[\\${ quote } ])` , 'g' ) , '$<escapedCharacter>' ) ;
32
17
}
33
18
34
19
/** @param {import('eslint').Rule.RuleContext } context */
You can’t perform that action at this time.
0 commit comments