Skip to content

Commit 0905dca

Browse files
author
Ronald Holshausen
authoredMar 7, 2020
Merge pull request #1042 from mikahjc/allow-punctuaion-in-path
Perform same check on character validity in pathIdentifier that identifier does
2 parents 2f1070b + 84276a3 commit 0905dca

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
 

‎core/model/src/main/kotlin/au/com/dius/pact/core/model/PathExpressions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fun pathIdentifier(
9292
val ch = chars.next()
9393
when {
9494
ch.value == '*' -> tokens.add(PathToken.Star)
95-
ch.value.isLetterOrDigit() || ch.value == '_' -> identifier(ch.value, chars, tokens, path)
95+
ch.value.isLetterOrDigit() || EXP_ALLOWED_SPECIAL_CHARS.contains(ch.value) -> identifier(ch.value, chars, tokens, path)
9696
else -> throw InvalidPathExpression("Expected either a \"*\" or path identifier in path expression \"$path\"" +
9797
" at index ${ch.index}")
9898
}

‎core/model/src/test/groovy/au/com/dius/pact/core/model/PathExpressionsSpec.groovy

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class PathExpressionsSpec extends Specification {
9090
where:
9191

9292
expression | result
93+
'$.container_records.example-ABC' | [PathToken.Root.INSTANCE, new PathToken.Field('container_records'), new PathToken.Field('example-ABC')]
94+
'$.container_records.example_ABC' | [PathToken.Root.INSTANCE, new PathToken.Field('container_records'), new PathToken.Field('example_ABC')]
9395
'$.container_records.example:ABC' | [PathToken.Root.INSTANCE, new PathToken.Field('container_records'), new PathToken.Field('example:ABC')]
9496
"\$.container_records['example:ABC']" | [PathToken.Root.INSTANCE, new PathToken.Field('container_records'), new PathToken.Field('example:ABC')]
9597
"\$.container_records['example/ABC']" | [PathToken.Root.INSTANCE, new PathToken.Field('container_records'), new PathToken.Field('example/ABC')]

0 commit comments

Comments
 (0)
Please sign in to comment.