go-urlrouter icon indicating copy to clipboard operation
go-urlrouter copied to clipboard

*splat routes failing

Open ghost opened this issue 12 years ago • 1 comments

(since Go 1.1?)

calls to rest.Route or rest.RouteObjectMethod fail for *splat routes

rest.RouteObjectMethod("GET", "/users/*username", users, "GetUser")

problem is in the trie package:

 } else if token[0] == '*' {
            // *splat case
            name := remaining
            remaining = ""
            if self.SplatChild == nil {
                    self.SplatChild = &node{}
                    self.SplatName = name
            }
            nextNode = self.SplatChild

token is arriving in urlencoded format so '*' is replaced with '%2A' and else if condition fails; does not affect :id parameters

ghost avatar Jun 04 '13 13:06 ghost

Thanks for the bug report, this is definitely due to a bad handling of the urlencoded strings. I'm gonna fix it. Note that it also affects gp-json-rest.

ant0ine avatar Jun 09 '13 02:06 ant0ine