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

more aggressive wildcards #24

@karlseguin

Description

@karlseguin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions