@@ -14,7 +14,7 @@ import (
1414 "net/http"
1515 "net/textproto"
1616 "net/url"
17- "path/filepath "
17+ "path"
1818 "strings"
1919
2020 "github.com/coder/websocket/internal/errd"
@@ -41,8 +41,8 @@ type AcceptOptions struct {
4141 // One would set this field to []string{"example.com"} to authorize example.com to connect.
4242 //
4343 // 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
4646 //
4747 // Please ensure you understand the ramifications of enabling this.
4848 // 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
9696 if ! opts .InsecureSkipVerify {
9797 err = authenticateOrigin (r , opts .OriginPatterns )
9898 if err != nil {
99- if errors .Is (err , filepath .ErrBadPattern ) {
99+ if errors .Is (err , path .ErrBadPattern ) {
100100 log .Printf ("websocket: %v" , err )
101101 err = errors .New (http .StatusText (http .StatusForbidden ))
102102 }
@@ -221,7 +221,7 @@ func authenticateOrigin(r *http.Request, originHosts []string) error {
221221 for _ , hostPattern := range originHosts {
222222 matched , err := match (hostPattern , u .Host )
223223 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 )
225225 }
226226 if matched {
227227 return nil
@@ -234,7 +234,7 @@ func authenticateOrigin(r *http.Request, originHosts []string) error {
234234}
235235
236236func 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 ))
238238}
239239
240240func selectSubprotocol (r * http.Request , subprotocols []string ) string {
0 commit comments