|
8 | 8 | "bytes"
|
9 | 9 | "errors"
|
10 | 10 | "fmt"
|
11 |
| - "path" |
12 | 11 | "strings"
|
13 | 12 | "sync"
|
14 | 13 | "sync/atomic"
|
@@ -193,51 +192,7 @@ func (c *Client) SetGONOSUMDB(list string) {
|
193 | 192 | var ErrGONOSUMDB = errors.New("skipped (listed in GONOSUMDB)")
|
194 | 193 |
|
195 | 194 | func (c *Client) skip(target string) bool {
|
196 |
| - return globsMatchPath(c.nosumdb, target) |
197 |
| -} |
198 |
| - |
199 |
| -// globsMatchPath reports whether any path prefix of target |
200 |
| -// matches one of the glob patterns (as defined by path.Match) |
201 |
| -// in the comma-separated globs list. |
202 |
| -// It ignores any empty or malformed patterns in the list. |
203 |
| -func globsMatchPath(globs, target string) bool { |
204 |
| - for globs != "" { |
205 |
| - // Extract next non-empty glob in comma-separated list. |
206 |
| - var glob string |
207 |
| - if i := strings.Index(globs, ","); i >= 0 { |
208 |
| - glob, globs = globs[:i], globs[i+1:] |
209 |
| - } else { |
210 |
| - glob, globs = globs, "" |
211 |
| - } |
212 |
| - if glob == "" { |
213 |
| - continue |
214 |
| - } |
215 |
| - |
216 |
| - // A glob with N+1 path elements (N slashes) needs to be matched |
217 |
| - // against the first N+1 path elements of target, |
218 |
| - // which end just before the N+1'th slash. |
219 |
| - n := strings.Count(glob, "/") |
220 |
| - prefix := target |
221 |
| - // Walk target, counting slashes, truncating at the N+1'th slash. |
222 |
| - for i := 0; i < len(target); i++ { |
223 |
| - if target[i] == '/' { |
224 |
| - if n == 0 { |
225 |
| - prefix = target[:i] |
226 |
| - break |
227 |
| - } |
228 |
| - n-- |
229 |
| - } |
230 |
| - } |
231 |
| - if n > 0 { |
232 |
| - // Not enough prefix elements. |
233 |
| - continue |
234 |
| - } |
235 |
| - matched, _ := path.Match(glob, prefix) |
236 |
| - if matched { |
237 |
| - return true |
238 |
| - } |
239 |
| - } |
240 |
| - return false |
| 195 | + return module.MatchPrefixPatterns(c.nosumdb, target) |
241 | 196 | }
|
242 | 197 |
|
243 | 198 | // Lookup returns the go.sum lines for the given module path and version.
|
|
0 commit comments