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

Skip to content

[router] optional prefix on routes does not work #34891

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
domnuprofesor opened this issue Dec 9, 2019 · 3 comments
Closed

[router] optional prefix on routes does not work #34891

domnuprofesor opened this issue Dec 9, 2019 · 3 comments

Comments

@domnuprofesor
Copy link

domnuprofesor commented Dec 9, 2019

Symfony version(s) affected: 4.4

Description
when importing routes from a resource file with a prefix, symfony will not match a valid route
with an allowable empty prefix unless the URL has a double / in it (//).

How to reproduce
Given this setting:

web:
  resource: '_routes.yaml'
  prefix: /{route_prefix?}
  requirements:
    route_prefix: valueA|valueB

and _routes.yaml:

product_list:
  path: '/brands/{brand_name}/{id}.html'
  controller: App\Controller\Brand\ProductController::index

the router will match:
/valueA/brands/{brand_name}/{id}.html and
/valueB/brands/{brand_name}/{id}.html but will not match
/brands/{brand_name}/{id}.html unless you provide the URL like this:
//brands/{brand_name}/{id}.html

Possible Solution
Allow for optional prefix values when importing routes.

@nicolas-grekas
Copy link
Member

Would you like to work on a fix?

@Tobion
Copy link
Contributor

Tobion commented Jan 28, 2020

Are optional prefix possible at all? I don't think that is supported. Ref. #31166

So //brands/{brand_name}/{id}.html just matches an empty string for {route_prefix} and /brands/{brand_name}/{id}.html is not supported as optional prefixes are not implemented AFAIK.

@Tobion Tobion added Feature and removed Bug labels Jan 28, 2020
@Tobion
Copy link
Contributor

Tobion commented Apr 10, 2020

Closing as there is no activity and it can be solved with two routes.

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

No branches or pull requests

5 participants