https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMEMICKLEIGORESTFUL-2435653 Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
		
			
				
	
	
		
			30 lines
		
	
	
		
			594 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			594 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package restful
 | 
						|
 | 
						|
import (
 | 
						|
	"fmt"
 | 
						|
	"regexp"
 | 
						|
)
 | 
						|
 | 
						|
var (
 | 
						|
	customVerbReg = regexp.MustCompile(":([A-Za-z]+)$")
 | 
						|
)
 | 
						|
 | 
						|
func hasCustomVerb(routeToken string) bool {
 | 
						|
	return customVerbReg.MatchString(routeToken)
 | 
						|
}
 | 
						|
 | 
						|
func isMatchCustomVerb(routeToken string, pathToken string) bool {
 | 
						|
	rs := customVerbReg.FindStringSubmatch(routeToken)
 | 
						|
	if len(rs) < 2 {
 | 
						|
		return false
 | 
						|
	}
 | 
						|
 | 
						|
	customVerb := rs[1]
 | 
						|
	specificVerbReg := regexp.MustCompile(fmt.Sprintf(":%s$", customVerb))
 | 
						|
	return specificVerbReg.MatchString(pathToken)
 | 
						|
}
 | 
						|
 | 
						|
func removeCustomVerb(str string) string {
 | 
						|
	return customVerbReg.ReplaceAllString(str, "")
 | 
						|
}
 |