2024-09-17 01:01:42 +00:00
|
|
|
package cors
|
|
|
|
|
2024-09-26 01:59:44 +00:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
2024-09-17 01:01:42 +00:00
|
|
|
|
|
|
|
type wildcard struct {
|
|
|
|
prefix string
|
|
|
|
suffix string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w wildcard) match(s string) bool {
|
2024-09-26 01:59:44 +00:00
|
|
|
return len(s) >= len(w.prefix)+len(w.suffix) &&
|
|
|
|
strings.HasPrefix(s, w.prefix) &&
|
|
|
|
strings.HasSuffix(s, w.suffix)
|
2024-09-17 01:01:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// convert converts a list of string using the passed converter function
|
2024-09-26 01:59:44 +00:00
|
|
|
func convert(s []string, f func(string) string) []string {
|
|
|
|
out := make([]string, len(s))
|
|
|
|
for i := range s {
|
|
|
|
out[i] = f(s[i])
|
2024-09-17 01:01:42 +00:00
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|