fix path issue

This commit is contained in:
Josh Baker 2016-08-21 05:35:33 -07:00
parent 1b1f52024e
commit 260ef19a2e
1 changed files with 42 additions and 44 deletions

View File

@ -137,8 +137,18 @@ func Get(json string, path string) Result {
// underscore characters. // underscore characters.
if path[i] >= '_' { if path[i] >= '_' {
continue continue
} else if path[i] <= '\\' { } else if path[i] == '.' {
if path[i] == '\\' { // append a new part
parts = append(parts, part{wild: wild, key: path[s:i]})
if wild {
wild = false // reset the wild flag
}
// set the starting index to one past the dot.
s = i + 1
} else if path[i] == '*' || path[i] == '?' {
// set the wild flag to indicate that the part is a wildcard.
wild = true
} else if path[i] == '\\' {
// go into escape mode. this is a slower path that // go into escape mode. this is a slower path that
// strips off the escape character from the part. // strips off the escape character from the part.
epart := []byte(path[s:i]) epart := []byte(path[s:i])
@ -170,18 +180,6 @@ func Get(json string, path string) Result {
// append the last part // append the last part
parts = append(parts, part{wild: wild, key: string(epart)}) parts = append(parts, part{wild: wild, key: string(epart)})
goto end_parts goto end_parts
} else if path[i] == '.' {
// append a new part
parts = append(parts, part{wild: wild, key: path[s:i]})
if wild {
wild = false // reset the wild flag
}
// set the starting index to one past the dot.
s = i + 1
} else if path[i] == '*' || path[i] == '?' {
// set the wild flag to indicate that the part is a wildcard.
wild = true
}
} }
} }
// append the last part // append the last part