@@ -14,7 +14,7 @@ import (
14
14
"net/http"
15
15
"net/textproto"
16
16
"net/url"
17
- "path/filepath "
17
+ "path"
18
18
"strings"
19
19
20
20
"nhooyr.io/websocket/internal/errd"
@@ -41,8 +41,8 @@ type AcceptOptions struct {
41
41
// One would set this field to []string{"example.com"} to authorize example.com to connect.
42
42
//
43
43
// Each pattern is matched case insensitively against the request origin host
44
- // with filepath .Match.
45
- // See https://golang.org/pkg/path/filepath/ #Match
44
+ // with path .Match.
45
+ // See https://golang.org/pkg/path/#Match
46
46
//
47
47
// Please ensure you understand the ramifications of enabling this.
48
48
// If used incorrectly your WebSocket server will be open to CSRF attacks.
@@ -96,7 +96,7 @@ func accept(w http.ResponseWriter, r *http.Request, opts *AcceptOptions) (_ *Con
96
96
if ! opts .InsecureSkipVerify {
97
97
err = authenticateOrigin (r , opts .OriginPatterns )
98
98
if err != nil {
99
- if errors .Is (err , filepath .ErrBadPattern ) {
99
+ if errors .Is (err , path .ErrBadPattern ) {
100
100
log .Printf ("websocket: %v" , err )
101
101
err = errors .New (http .StatusText (http .StatusForbidden ))
102
102
}
@@ -221,7 +221,7 @@ func authenticateOrigin(r *http.Request, originHosts []string) error {
221
221
for _ , hostPattern := range originHosts {
222
222
matched , err := match (hostPattern , u .Host )
223
223
if err != nil {
224
- return fmt .Errorf ("failed to parse filepath pattern %q: %w" , hostPattern , err )
224
+ return fmt .Errorf ("failed to parse path pattern %q: %w" , hostPattern , err )
225
225
}
226
226
if matched {
227
227
return nil
@@ -234,7 +234,7 @@ func authenticateOrigin(r *http.Request, originHosts []string) error {
234
234
}
235
235
236
236
func match (pattern , s string ) (bool , error ) {
237
- return filepath .Match (strings .ToLower (pattern ), strings .ToLower (s ))
237
+ return path .Match (strings .ToLower (pattern ), strings .ToLower (s ))
238
238
}
239
239
240
240
func selectSubprotocol (r * http.Request , subprotocols []string ) string {
0 commit comments