Skip to content

Commit afde356

Browse files
authored
chore: use slices contains instead of loop (#36)
1 parent 709cb18 commit afde356

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

keyfetch.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"log/slog"
1010
"net/http"
1111
"net/url"
12+
"slices"
1213
"sync"
1314
"time"
1415
)
@@ -239,10 +240,8 @@ func validateHost(urlStr string, allowedHosts []string, urlType string) error {
239240
// Get hostname without port for comparison
240241
hostname := parsed.Hostname()
241242

242-
for _, allowed := range allowedHosts {
243-
if hostname == allowed {
244-
return nil
245-
}
243+
if slices.Contains(allowedHosts, hostname) {
244+
return nil
246245
}
247246

248247
return fmt.Errorf("%s host '%s' is not in the allowed hosts list", urlType, hostname)

0 commit comments

Comments
 (0)