From 9c4d9fa40cc447871901f49fb8d6d76f3dfc3ec3 Mon Sep 17 00:00:00 2001 From: HowJMay Date: Tue, 21 Sep 2021 23:55:26 +0800 Subject: [PATCH] x/mod/module: accept trailing slash in MatchPrefixPattern Trailing slash of glob is not accepted in MatchPrefixPattern. close #48513 --- src/cmd/vendor/golang.org/x/mod/module/module.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/vendor/golang.org/x/mod/module/module.go b/src/cmd/vendor/golang.org/x/mod/module/module.go index 89bd3ede277..dd14dc771ce 100644 --- a/src/cmd/vendor/golang.org/x/mod/module/module.go +++ b/src/cmd/vendor/golang.org/x/mod/module/module.go @@ -811,6 +811,10 @@ func MatchPrefixPatterns(globs, target string) bool { continue } + // Remove the trailing slash in glob + if glob[len(glob)-1] == '/' { + glob = glob[:len(glob)-1] + } // A glob with N+1 path elements (N slashes) needs to be matched // against the first N+1 path elements of target, // which end just before the N+1'th slash.