MCPcopy Create free account
hub / github.com/PuerNya/git-proxy / EasyWildcardMatch

Function EasyWildcardMatch

main.go:492–515  ·  view source on GitHub ↗
(s string, p string)

Source from the content-addressed store, hash-verified

490}
491
492func EasyWildcardMatch(s string, p string) bool {
493 if p == "*" || (s == "" && p == "") {
494 return true
495 }
496 if s == "" || p == "" {
497 return false
498 }
499 pr := []rune(p)
500 sr := []rune(s)
501 var nextS, nextP string
502 if len(pr) > 1 {
503 nextP = string(pr[1:])
504 }
505 if len(sr) > 1 {
506 nextS = string(sr[1:])
507 }
508 if pr[0] == '*' {
509 return EasyWildcardMatch(s, nextP) || EasyWildcardMatch(nextS, nextP) || EasyWildcardMatch(nextS, p)
510 } else if pr[0] == '?' {
511 return EasyWildcardMatch(nextS, nextP)
512 } else {
513 return sr[0] == pr[0] && EasyWildcardMatch(nextS, nextP)
514 }
515}
516
517func listenTCP(address M.Socksaddr) net.Listener {
518 var listener net.Listener

Callers 1

MatchMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected