Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunKoyalwar committed Aug 25, 2023
2 parents cffe183 + 92bd1da commit 2c94769
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
10 changes: 10 additions & 0 deletions strings/stringsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ func HasPrefixAny(s string, prefixes ...string) bool {
return false
}

// HasPrefixAnyI is case insensitive HasPrefixAny
func HasPrefixAnyI(s string, prefixes ...string) bool {
for _, prefix := range prefixes {
if HasPrefixI(s, prefix) {
return true
}
}
return false
}

// HasSuffixAny checks if the string ends with any specified suffix
func HasSuffixAny(s string, suffixes ...string) bool {
for _, suffix := range suffixes {
Expand Down
13 changes: 13 additions & 0 deletions strings/stringsutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ func TestHasPrefixAny(t *testing.T) {
}
}

func TestHasPrefixAnyI(t *testing.T) {
tests := map[string]prefixsuffixtest{
"A b c": {Prefixes: []string{"a"}, Result: true},
"A B c d": {Prefixes: []string{"a b", "a"}, Result: true},
"a b c d e": {Prefixes: []string{"b", "o", "A"}, Result: true},
"test test": {Prefixes: []string{"a", "b"}, Result: false},
}
for str, test := range tests {
res := HasPrefixAnyI(str, test.Prefixes...)
require.Equalf(t, test.Result, res, "test: %s prefixes: %+v result: %s", str, test.Prefixes, res)
}
}

func TestHasSuffixAny(t *testing.T) {
tests := map[string]prefixsuffixtest{
"a b c": {Suffixes: []string{"c"}, Result: true},
Expand Down
16 changes: 16 additions & 0 deletions url/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,19 @@ func TestURLFragment(t *testing.T) {
require.Equalf(t, v.expectedFragment, urlx.Fragment, "got error for url %v", v.inputURL)
}
}

func TestUnicodeEscapeWithUnsafe(t *testing.T) {
testcases := []struct {
input string
expected string
}{
{"https://scanme.sh/%u002e%u002e/%u002e%u002e/1.txt.it", "https://scanme.sh/%u002e%u002e/%u002e%u002e/1.txt.it"},
}
DisableAutoCorrect = true

for _, v := range testcases {
urlx, err := ParseURL(v.input, true)
require.Nilf(t, err, "got error for url %v", v.input)
require.Equal(t, v.expected, urlx.String())
}
}

0 comments on commit 2c94769

Please sign in to comment.