2022-07-07 13:47:21 +00:00
|
|
|
package domain_test
|
2022-07-02 14:55:10 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-07-07 13:47:21 +00:00
|
|
|
"github.com/sagernet/sing-box/common/domain"
|
|
|
|
|
2022-07-02 14:55:10 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMatch(t *testing.T) {
|
2022-07-10 14:00:28 +00:00
|
|
|
t.Parallel()
|
2022-07-02 14:55:10 +00:00
|
|
|
r := require.New(t)
|
2022-07-07 13:47:21 +00:00
|
|
|
matcher := domain.NewMatcher([]string{"domain.com"}, []string{"suffix.com", ".suffix.org"})
|
2022-07-02 14:55:10 +00:00
|
|
|
r.True(matcher.Match("domain.com"))
|
|
|
|
r.False(matcher.Match("my.domain.com"))
|
|
|
|
r.True(matcher.Match("suffix.com"))
|
|
|
|
r.True(matcher.Match("my.suffix.com"))
|
|
|
|
r.False(matcher.Match("suffix.org"))
|
|
|
|
r.True(matcher.Match("my.suffix.org"))
|
|
|
|
}
|