sumdb: replace globsMatchPath with module.MatchPrefixPatterns

In CL 239797, src/cmd/go/internal/str.GlobsMatchPath was replicated as
module.MatchPrefixPatterns. This redundancy eliminates the need for
globsMatchPath. This CL replaces calls to globsMatchPath with
module.MatchPrefixPatterns and removes the now redundant globsMatchPath.

Change-Id: Idd6fc10e7cf24d7b9603fa17edb2460d50b2e4aa
Reviewed-on: https://go-review.googlesource.com/c/mod/+/539815
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/sumdb/client.go b/sumdb/client.go
index aecdc68..04c6e24 100644
--- a/sumdb/client.go
+++ b/sumdb/client.go
@@ -8,7 +8,6 @@
 	"bytes"
 	"errors"
 	"fmt"
-	"path"
 	"strings"
 	"sync"
 	"sync/atomic"
@@ -193,51 +192,7 @@
 var ErrGONOSUMDB = errors.New("skipped (listed in GONOSUMDB)")
 
 func (c *Client) skip(target string) bool {
-	return globsMatchPath(c.nosumdb, target)
-}
-
-// globsMatchPath reports whether any path prefix of target
-// matches one of the glob patterns (as defined by path.Match)
-// in the comma-separated globs list.
-// It ignores any empty or malformed patterns in the list.
-func globsMatchPath(globs, target string) bool {
-	for globs != "" {
-		// Extract next non-empty glob in comma-separated list.
-		var glob string
-		if i := strings.Index(globs, ","); i >= 0 {
-			glob, globs = globs[:i], globs[i+1:]
-		} else {
-			glob, globs = globs, ""
-		}
-		if glob == "" {
-			continue
-		}
-
-		// 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.
-		n := strings.Count(glob, "/")
-		prefix := target
-		// Walk target, counting slashes, truncating at the N+1'th slash.
-		for i := 0; i < len(target); i++ {
-			if target[i] == '/' {
-				if n == 0 {
-					prefix = target[:i]
-					break
-				}
-				n--
-			}
-		}
-		if n > 0 {
-			// Not enough prefix elements.
-			continue
-		}
-		matched, _ := path.Match(glob, prefix)
-		if matched {
-			return true
-		}
-	}
-	return false
+	return module.MatchPrefixPatterns(c.nosumdb, target)
 }
 
 // Lookup returns the go.sum lines for the given module path and version.