Skip to content

Commit 2a4dcc8

Browse files
author
Matt Fellows
committed
fix: remove double escaping for regex matcher. Fixes #119
1 parent 649c7a8 commit 2a4dcc8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

dsl/matcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ func pluckParams(srcType reflect.Type, pactTag string) params {
412412
if _, err := fmt.Sscanf(components[0], "example=%s", &params.str.example); err != nil {
413413
triggerInvalidPactTagPanic(pactTag, err)
414414
}
415-
params.str.regEx = strings.Replace(components[1], `\`, `\\`, -1)
415+
params.str.regEx = components[1]
416416

417417
} else if exampleRegex.Match([]byte(pactTag)) {
418418
components := strings.Split(pactTag, "example=")

dsl/matcher_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ func TestMatch(t *testing.T) {
617617
src: dateDTO{},
618618
},
619619
want: StructMatcher{
620-
"date": Term("2000-01-01", `^\\d{4}-\\d{2}-\\d{2}$`),
620+
"date": Term("2000-01-01", `^\d{4}-\d{2}-\d{2}$`),
621621
},
622622
},
623623
{
@@ -863,7 +863,7 @@ func Test_pluckParams(t *testing.T) {
863863
},
864864
str: stringParams{
865865
example: "33",
866-
regEx: `\\d{2}`,
866+
regEx: `\d{2}`,
867867
},
868868
},
869869
},

0 commit comments

Comments
 (0)