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

parameters whose value is their :name are dropped #16

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

parameters whose value is their :name are dropped #16

skwerlman opened this issue Mar 19, 2016 · 1 comment

Comments

@skwerlman
Copy link
Contributor

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
Copy link
Contributor Author

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 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