Skip to content

Commit

Permalink
Split file
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 6, 2022
1 parent fc5767c commit e36b7de
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/config/normalize/lib/star_dot_path/parsing/parse.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { parseAnyToken } from '../tokens/any.js'
import { hasIndex, parseIndexToken } from '../tokens/array.js'
import { SPECIAL_CHARS } from '../tokens/escape.js'
import { parsePropToken } from '../tokens/prop.js'
import { parseRegExpToken } from '../tokens/regexp.js'
import {
Expand All @@ -8,7 +9,6 @@ import {
ANY,
MINUS,
REGEXP_DELIM,
SPECIAL_CHARS,
} from '../tokens/special.js'

import { normalizePath } from './normalize.js'
Expand Down
16 changes: 16 additions & 0 deletions src/config/normalize/lib/star_dot_path/tokens/escape.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ESCAPE, SEPARATOR, ANY, MINUS, REGEXP_DELIM } from './special.js'

export const SPECIAL_CHARS = new Set([
ESCAPE,
SEPARATOR,
ANY,
MINUS,
REGEXP_DELIM,
])

// Escape special characters
export const escapeSpecialChars = function (string) {
return string.replace(SPECIAL_CHARS_REGEXP, '\\$&')
}

const SPECIAL_CHARS_REGEXP = /[\\.*]|^[/-]/gu
3 changes: 2 additions & 1 deletion src/config/normalize/lib/star_dot_path/tokens/prop.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { escapeSpecialChars } from './escape.js'
import { isRecurseObject } from './recurse.js'
import { SEPARATOR, escapeSpecialChars } from './special.js'
import { SEPARATOR } from './special.js'

// Check if a token is a property name string
export const isPropToken = function (token) {
Expand Down
3 changes: 2 additions & 1 deletion src/config/normalize/lib/star_dot_path/tokens/regexp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { escapeSpecialChars } from './escape.js'
import { isRecurseObject } from './recurse.js'
import { REGEXP_DELIM, escapeSpecialChars } from './special.js'
import { REGEXP_DELIM } from './special.js'

// Check if a token is a /.../ RegExp
export const isRegExpToken = function (token) {
Expand Down
14 changes: 0 additions & 14 deletions src/config/normalize/lib/star_dot_path/tokens/special.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,3 @@ export const SEPARATOR = '.'
export const ANY = '*'
export const MINUS = '-'
export const REGEXP_DELIM = '/'
export const SPECIAL_CHARS = new Set([
ESCAPE,
SEPARATOR,
ANY,
MINUS,
REGEXP_DELIM,
])

// Escape special characters
export const escapeSpecialChars = function (string) {
return string.replace(SPECIAL_CHARS_REGEXP, '\\$&')
}

const SPECIAL_CHARS_REGEXP = /[\\.*]|^[/-]/gu

0 comments on commit e36b7de

Please sign in to comment.