-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG] Path template variables not correctly parsed with dot #2437
Comments
I looked at the code and found that Lines 96 to 120 in d20161d
The documentation does not mention the fact that the I found that the implementation was jumping more hoops than needed. The Note the def _parse_path_variables(pathname, path_template):
"""
creates the dict of path variables passed to the layout
e.g. path_template= "/asset/<asset_id>"
if pathname provided by the browser is "/assets/a100"
returns **{"asset_id": "a100"}
"""
pattern = re.compile(
re.sub(
"<(?P<var>.*?)>", r"(?P<\g<var>>.*)",
re.escape(path_template)
)
)
match = pattern.match(pathname)
return match.groupdict() if match else None I am happy to make this into a PR if you agree in principle. |
Thanks @jowlo - nice detective work, and your proposal looks good. We would welcome a PR! Try and add a test of the specific bug you encountered with dots in the path; so far the pages tests are all integration tests (mostly in |
Bug description
Path template variables are not parsed/populated correctly when using a dot (
.
) as seperator between placeholders as in/dot/<foo>.<bar>/
.When using
/dot/<foo>.<bar>/
as path template, a request to/dot/abc.def
should result in a call tolayout(foo='abc', bar='def')
.Instead there is a call to
layout(foo='abc.de', part=None)
. (Note the missinge
at the end)Using
/dash/<foo>-<bar>/
as path template, the request url is handled as expected and variables are parsed/populated correctly.Expected behavior
Variables should be parsed as expected and correctly independent of characters between seperators.
Minimal example
Environment
The text was updated successfully, but these errors were encountered: