Skip to content

Commit

Permalink
fix: remove double escaping for regex matcher. Fixes #119
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Fellows committed Oct 23, 2019
1 parent 649c7a8 commit 2a4dcc8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dsl/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func pluckParams(srcType reflect.Type, pactTag string) params {
if _, err := fmt.Sscanf(components[0], "example=%s", &params.str.example); err != nil {
triggerInvalidPactTagPanic(pactTag, err)
}
params.str.regEx = strings.Replace(components[1], `\`, `\\`, -1)
params.str.regEx = components[1]

} else if exampleRegex.Match([]byte(pactTag)) {
components := strings.Split(pactTag, "example=")
Expand Down
4 changes: 2 additions & 2 deletions dsl/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ func TestMatch(t *testing.T) {
src: dateDTO{},
},
want: StructMatcher{
"date": Term("2000-01-01", `^\\d{4}-\\d{2}-\\d{2}$`),
"date": Term("2000-01-01", `^\d{4}-\d{2}-\d{2}$`),
},
},
{
Expand Down Expand Up @@ -863,7 +863,7 @@ func Test_pluckParams(t *testing.T) {
},
str: stringParams{
example: "33",
regEx: `\\d{2}`,
regEx: `\d{2}`,
},
},
},
Expand Down

0 comments on commit 2a4dcc8

Please sign in to comment.