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" import "strings"
// splits an URL without empty sets // SplitURL without empty sets
func splitURL(url string) []string { func SplitURL(url string) []string {
trimmed := strings.Trim(url, " /\t\r\n") trimmed := strings.Trim(url, " /\t\r\n")
split := strings.Split(trimmed, "/") split := strings.Split(trimmed, "/")

View File

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

View File

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

View File

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