Skip to content
This repository was archived by the owner on Dec 11, 2020. It is now read-only.

more aggressive wildcards #24

Open
karlseguin opened this issue Aug 30, 2016 · 0 comments
Open

more aggressive wildcards #24

karlseguin opened this issue Aug 30, 2016 · 0 comments

Comments

@karlseguin
Copy link

karlseguin commented Aug 30, 2016

I noticed that a route of:

r:match('GET', '*', ...)

doesn't match

'GET', '/'

Or, more globally, it doesn't match zero-elements.

I changed match_one_path and added the if block within the for:

local function match_one_path(node, path, f)
  for token in path:gmatch("[^/.]+") do
    node[token] = node[token] or {}
    if token == '*' and not node['LEAF'] then
      node['LEAF'] = f
    end
    node = node[token]
  end
  node["LEAF"] = f
end

All tests pass, but I'm loath to open a PR as this would probably break someone's expectations.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant