Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Consider adding the trailing separator as optional for optional values #5918

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

Closed
fabpot opened this issue Nov 6, 2012 · 4 comments
Closed
Labels

Comments

@fabpot
Copy link
Member

fabpot commented Nov 6, 2012

When defining a route like this:

/foo/{param}

with a default value for param, you can omit the param and Symfony will match a URL like /foo. But it won't match /foo/.

Would it make sense to allow it? What are the consequences on BC?

Or do we need to introduce a special syntax for optional parameters:

/foo/{?param}

/foo{/?param}

see fabpot/Silex#485

@Seldaek
Copy link
Member

Seldaek commented Nov 6, 2012

IMO /foo/ should work indeed, it has annoyed me a couple times, it's not part of the param so I don't know why it would be stripped automatically.

@lewiji
Copy link

lewiji commented Nov 12, 2012

Agreed, as a workaround to other bugs/behaviour with missing slashes in URLs we change the server request uri so that it always has a trailing slash. This unfortunately breaks optional values.

@Tobion
Copy link
Contributor

Tobion commented Mar 7, 2013

This can be achieved with #5424.

So what /foo/{param} currently means is /foo(/{param}).
And with /foo/({param}) it would match /foo/ as you wanted. And /foo would redirect to /foo/ as we already do.

@Tobion
Copy link
Contributor

Tobion commented Jan 16, 2015

Closing as duplicate of ##5424.

@Tobion Tobion closed this as completed Jan 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants