make splitURL public

This commit is contained in:
Adrien Marquès 2020-03-16 09:26:10 +01:00
parent 1b4922693b
commit c32b038da2
Signed by: xdrm-brackets
GPG Key ID: D75243CA236D825E
4 changed files with 7 additions and 13 deletions

View File

@ -2,8 +2,8 @@ package config
import "strings"
// splits an URL without empty sets
func splitURL(url string) []string {
// SplitURL without empty sets
func SplitURL(url string) []string {
trimmed := strings.Trim(url, " /\t\r\n")
split := strings.Split(trimmed, "/")

View File

@ -55,8 +55,8 @@ func (server *Server) collide() error {
continue
}
aParts := splitURL(aService.Pattern)
bParts := splitURL(bService.Pattern)
aParts := SplitURL(aService.Pattern)
bParts := SplitURL(bService.Pattern)
// not same size
if len(aParts) != len(bParts) {

View File

@ -54,7 +54,7 @@ func (svc *Service) checkPattern() error {
}
// for each slash-separated chunk
parts := splitURL(svc.Pattern)
parts := SplitURL(svc.Pattern)
for i, part := range parts {
if len(part) < 1 {
return ErrInvalidPattern
@ -154,8 +154,8 @@ func (svc *Service) checkAndFormatInput(types []datatype.T) error {
// checks if an uri matches the service's pattern
func (svc *Service) matchPattern(uri string) bool {
uriparts := splitURL(uri)
parts := splitURL(svc.Pattern)
uriparts := SplitURL(uri)
parts := SplitURL(svc.Pattern)
// fail if size differ
if len(uriparts) != len(parts) {

View File

@ -45,9 +45,3 @@ type BraceCapture struct {
Index int
Ref *Parameter
}
// links to the related URI parameter and hold a value
type braceCaptureValue struct {
BraceCapture
Value interface{}
}