Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Commit

Permalink
👌 Escape special chars in the regex 😳
Browse files Browse the repository at this point in the history
  • Loading branch information
peteclark-ft committed Aug 25, 2017
1 parent 864dd9b commit d6bc045
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func main() {
Name: "whitelistRegex",
Desc: "The regex to use to filter messages based on Origin-System-Id.",
EnvVar: "WHITELIST_REGEX",
Value: "http://cmdb.ft.com/systems/methode-web-pub",
Value: "http://cmdb\\.ft\\.com/systems/methode-web-pub",
})

app.Action = func() {
Expand Down
8 changes: 4 additions & 4 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/stretchr/testify/assert"
)

func TestHandleMessageInvalidWhitelist(t *testing.T) {
whitelist = regexp.MustCompile("http://cmdb.ft.com/systems/methode-web-pub")
func TestHandleMessageWithUnsupportedSystemCode(t *testing.T) {
whitelist = regexp.MustCompile("http://cmdb\\.ft\\.com/systems/methode-web-pub")

msg := kafka.FTMessage{}
msg.Headers = make(map[string]string)
Expand All @@ -25,8 +25,8 @@ func TestHandleMessageInvalidWhitelist(t *testing.T) {
assert.Equal(t, "Skipping annotations published with Origin-System-Id \"http://cmdb.ft.com/systems/pac\". It does not match the configured whitelist.", logLine)
}

func TestHandleMessageValidWhitelist(t *testing.T) {
whitelist = regexp.MustCompile("http://cmdb.ft.com/systems/methode-web-pub")
func TestHandleMessageWithSupportedSystemCode(t *testing.T) {
whitelist = regexp.MustCompile("http://cmdb\\.ft\\.com/systems/methode-web-pub")

msg := kafka.FTMessage{}
msg.Headers = make(map[string]string)
Expand Down

0 comments on commit d6bc045

Please sign in to comment.