Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite8c9319

Browse files
committed
Replace filepath.Match with path.Match
OS-specific behaviour is not necessary. This PR replaces filepath.Matchwith path.Match and also updated the documentation to reflect that.
1 parentbd07a64 commite8c9319

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎accept.go‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"net/http"
1515
"net/textproto"
1616
"net/url"
17-
"path/filepath"
17+
"path"
1818
"strings"
1919

2020
"nhooyr.io/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-
// withfilepath.Match.
45-
// See https://golang.org/pkg/path/filepath/#Match
44+
// withpath.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
iferr!=nil {
99-
iferrors.Is(err,filepath.ErrBadPattern) {
99+
iferrors.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:=rangeoriginHosts {
222222
matched,err:=match(hostPattern,u.Host)
223223
iferr!=nil {
224-
returnfmt.Errorf("failed to parsefilepath pattern %q: %w",hostPattern,err)
224+
returnfmt.Errorf("failed to parsepath pattern %q: %w",hostPattern,err)
225225
}
226226
ifmatched {
227227
returnnil
@@ -234,7 +234,7 @@ func authenticateOrigin(r *http.Request, originHosts []string) error {
234234
}
235235

236236
funcmatch(pattern,sstring) (bool,error) {
237-
returnfilepath.Match(strings.ToLower(pattern),strings.ToLower(s))
237+
returnpath.Match(strings.ToLower(pattern),strings.ToLower(s))
238238
}
239239

240240
funcselectSubprotocol(r*http.Request,subprotocols []string)string {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp