alien icon indicating copy to clipboard operation
alien copied to clipboard

Problem with catch all url pattern

Open davidaq opened this issue 6 years ago • 2 comments

I like the simplicity and well documented nature of the little routing framework. Yet I found that the "catch all" routing pattern suggested in the document doesn't work at all (revision a9d769893b801081204defeb3466c3b13972edb4).

I eventually resolved the problem my self, and here's what I've done:

func (n *node) insert(pattern string, val *route) error {
   // ....
  Loop: for k, ch := range pattern { // add a label
    // ...
    swich ch {
       // ...
       case '*': 
          level = level.branch(ch, nil, nodeCatchAll) 
          break Loop // break here if meet a catch all
       // ...
    }
    // ...
  }

Another issue is that you use a csv like format to serialize parsed params, and this will cause parsing problem if there are , or : inside the matched url.

davidaq avatar Aug 24 '18 10:08 davidaq

@davidaq apologies , I missed this one. Can you please expand on what you mean by it is not working at all.

And how do I reproduce this?

Thanks.

gernest avatar Aug 25 '18 14:08 gernest