Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameters whose value is their :name are dropped #16

Open
skwerlman opened this issue Mar 19, 2016 · 1 comment

Comments

Projects
None yet
1 participant
@skwerlman
Copy link
Contributor

commented Mar 19, 2016

If you define a route such as

r:get('/api/:node', doTheThing)

and access the URL

http://someSite.local/api/:node

the param table passed to doTheThing contains no entry named node. This only happens if the value for node should have been exactly :node.

@skwerlman

This comment has been minimized.

Copy link
Contributor Author

commented Jun 8, 2016

A more concrete example:

require 'pl.pretty' -- penlight
local router = require 'router'
local r = router.new()

local function printParams(params)
  print(pretty.write(params))
end

r:get('/:foo/:bar', printParams)

r:execute('GET', '/:foo/value') -- {bar = "value"}               -- wrong
r:execute('GET', '/foo/value') -- {foo = "foo", bar = "value"}   -- correct
r:execute('GET', '/:bar/value') -- {foo = ":bar", bar = "value"} -- correct
r:execute('GET', '/value/:foo') -- {foo = "value", bar = ":foo"} -- correct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.