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

deparam returns different results if leading slash is included/not #132

Open
matthewp opened this issue Dec 13, 2017 · 1 comment
Open

Comments

@matthewp
Copy link
Contributor

If you have a route like:

route("/{page}", { page: "home" });

route.deparam("/"); // { page: "home" }
route.deparam(""); // undefined

vs.

route("{page}", { page: "home" });

route.deparam("/"); // undefined
route.deparam(""); // { page: "home" }

This is not ideal, maybe we just say that you must exclude the leading slash?

@mjstahl
Copy link

mjstahl commented Oct 3, 2018

I would go through the extra effort to allow both. Assume route("{page}") is equivalent to route("/{page}") and vice versa.

Therefore we would also have to assume that route.deparam("/") === route.deparam("")

You could, in documentation, recommend a particular way of doing things (like excluding the leading slash) but it is inevitable that someone will mess it up and not know why. And I think it is the framework's job to compensate for this sort of 'foot-gun' stuff.

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

No branches or pull requests

2 participants