Skip to content

Commit

Permalink
extended domain validation (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoldierOfHeart authored Feb 9, 2021
1 parent d15ed7f commit 6ae7bdc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (
}
markdownSymbols = []string{"*", "_", "`", "["}
regCommandName = regexp.MustCompile(
`^https://?[\da-z.-]+\.(retailcrm\.(ru|pro|es)|ecomlogic\.com|simlachat\.(com|ru))/?$`)
`^https://?[\da-z.-]+\.(retailcrm\.(ru|pro|es)|ecomlogic\.com|simla(chat)?\.(com|ru))/?$`)
slashRegex = regexp.MustCompile(`/+$`)
)

Expand Down
22 changes: 17 additions & 5 deletions core/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,22 @@ func (s *ValidatorSuite) Test_ValidationFails() {
}

func (s *ValidatorSuite) Test_ValidationSuccess() {
conn := Connection{
Key: "key",
URL: "https://test.retailcrm.pro",
domains := []string{
"https://asd.retailcrm.ru",
"https://test.retailcrm.pro",
"https://raisa.retailcrm.es",
"https://blabla.simla.com",
"https://blabla.simla.ru",
"https://blabla.simlachat.com",
"https://blabla.simlachat.ru",
}

for _, domain := range domains {
conn := Connection{
Key: "key",
URL: domain,
}
err := s.engine.Struct(conn)
assert.NoError(s.T(), err, s.getError(err))
}
err := s.engine.Struct(conn)
assert.NoError(s.T(), err, s.getError(err))
}

0 comments on commit 6ae7bdc

Please sign in to comment.