diff --git a/internal/uri/parser/public.go b/internal/uri/parser/public.go index 8f8cfeb..cfc5ad7 100644 --- a/internal/uri/parser/public.go +++ b/internal/uri/parser/public.go @@ -73,17 +73,17 @@ func (s Scheme) GetMatch(n uint8) ([]string, error) { /* (2) Iterate to find index (exclude strings) */ ni := -1 - for i, l := 0, len(s) ; i < l ; i++ { + for _, m := range s { // ignore strings - if len(s[i].pat) > 0 { continue } + if len(m.pat) > 0 { continue } // increment match counter : ni ni++ // if expected index -> return matches if uint8(ni) == n { - return s[i].buf, nil + return m.buf, nil } } @@ -91,4 +91,25 @@ func (s Scheme) GetMatch(n uint8) ([]string, error) { /* (3) If nothing found -> return empty set */ return nil, fmt.Errorf("Index out of range (max: %d)", ni) +} + + + + +// GetAllMatch returns all the indexed match (excluding string matchers) +func (s Scheme) GetAllMatch() [][]string { + + match := make([][]string, 0, len(s)) + + for _, m := range s { + + // ignore strings + if len(m.pat) > 0 { continue } + + match = append(match, m.buf) + + } + + return match + } \ No newline at end of file