From 6ae7bdc9a344c85de1701e6ec570c1dd31059733 Mon Sep 17 00:00:00 2001 From: Yura Date: Tue, 9 Feb 2021 15:57:34 +0300 Subject: [PATCH] extended domain validation (#24) --- core/config.go | 2 +- core/validator_test.go | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/core/config.go b/core/config.go index 9f89266..14922f8 100644 --- a/core/config.go +++ b/core/config.go @@ -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(`/+$`) ) diff --git a/core/validator_test.go b/core/validator_test.go index 11def19..76f3db4 100644 --- a/core/validator_test.go +++ b/core/validator_test.go @@ -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)) }