Fix a couple of edge cases in parsePath
This commit is contained in:
1 parent
1f7fa7f1b3
commit
78ecbba875
1 file changed
+18
-14
+18
-14
@@ -235,28 +235,32 @@ parseAlias = (pattern, start, res) ->
|
|||||||
|
|
||||||
parsePath = (pattern, start, res) ->
|
parsePath = (pattern, start, res) ->
|
||||||
path = []
|
path = []
|
||||||
i = j = start ? 0
|
i = start ? 0
|
||||||
|
|
||||||
# Colon separator is needed for parseAlias
|
# Colon separator is needed for parseAlias
|
||||||
while j < pattern.length and pattern[j] != ':'
|
if i < pattern.length and pattern[i] != ':'
|
||||||
if pattern[j] == '.'
|
while true
|
||||||
n = pattern.slice(i, j)
|
if pattern[i] == '['
|
||||||
path.push(if n == '*' then null else n)
|
i = parseAlias(pattern, i + 1, path) + 1
|
||||||
i = j + 1
|
else
|
||||||
else if pattern[j] == '[' and i == j
|
j = i
|
||||||
j = parseAlias(pattern, j + 1, path) + 1
|
while i < pattern.length and pattern[i] != ':' and pattern[i] != '.'
|
||||||
i = j + 1
|
++ i
|
||||||
++ j
|
n = pattern.slice(j, i)
|
||||||
|
path.push(if n == '*' then null else n)
|
||||||
|
|
||||||
if j > 0
|
if i >= pattern.length or pattern[i] == ':'
|
||||||
n = pattern.slice(i, j)
|
break
|
||||||
path.push(if n == '*' then null else n)
|
else if pattern[i] != '.'
|
||||||
|
throw new Error('Invalid alias expression')
|
||||||
|
|
||||||
|
++ i
|
||||||
|
|
||||||
if not res?
|
if not res?
|
||||||
return path
|
return path
|
||||||
|
|
||||||
res.push(path)
|
res.push(path)
|
||||||
return j
|
return i
|
||||||
|
|
||||||
|
|
||||||
exports.UNDEFINED_TYPE = UNDEFINED_TYPE
|
exports.UNDEFINED_TYPE = UNDEFINED_TYPE
|
||||||
|
|||||||
Reference in new issue
Block a user