File tree 1 file changed +14
-12
lines changed 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -178,14 +178,16 @@ const CODE_BACKSLASH = 92;
178
178
const CODE_SLASH = 47 ;
179
179
180
180
function slashDelimiter ( input , delimiterCode ) {
181
+ if ( delimiterCode === CODE_BACKSLASH ) throw new Error ( "delimiter cannot be backslash" ) ;
181
182
let afterBackslash = false ;
182
183
for ( let i = 0 , n = input . length ; i < n ; ++ i ) {
183
- const code = input . charCodeAt ( i ) ;
184
- if ( code === CODE_BACKSLASH && ! afterBackslash ) {
185
- afterBackslash = true ;
186
- continue ;
187
- }
188
- switch ( code ) {
184
+ switch ( input . charCodeAt ( i ) ) {
185
+ case CODE_BACKSLASH :
186
+ if ( ! afterBackslash ) {
187
+ afterBackslash = true ;
188
+ continue ;
189
+ }
190
+ break ;
189
191
case delimiterCode :
190
192
if ( afterBackslash ) {
191
193
( input = input . slice ( 0 , i - 1 ) + input . slice ( i ) ) , -- i , -- n ; // remove backslash
@@ -209,13 +211,13 @@ function slashDelimiter(input, delimiterCode) {
209
211
function slashUnescape ( input ) {
210
212
let afterBackslash = false ;
211
213
for ( let i = 0 , n = input . length ; i < n ; ++ i ) {
212
- const code = input . charCodeAt ( i ) ;
213
- if ( code === CODE_BACKSLASH && ! afterBackslash ) {
214
- afterBackslash = true ;
215
- continue ;
216
- }
217
- switch ( code ) {
214
+ switch ( input . charCodeAt ( i ) ) {
218
215
case CODE_BACKSLASH :
216
+ if ( ! afterBackslash ) {
217
+ afterBackslash = true ;
218
+ continue ;
219
+ }
220
+ // eslint-disable-next-line no-fallthrough
219
221
case CODE_SLASH :
220
222
if ( afterBackslash ) {
221
223
( input = input . slice ( 0 , i - 1 ) + input . slice ( i ) ) , -- i , -- n ; // remove backslash
You can’t perform that action at this time.
0 commit comments