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

Router rule: (:alphanum) doesn't work #498

Closed
nowackipawel opened this issue May 16, 2017 · 4 comments
Closed

Router rule: (:alphanum) doesn't work #498

nowackipawel opened this issue May 16, 2017 · 4 comments

Comments

@nowackipawel
Copy link
Contributor

Docs: (:alphanum) will match any string of alphabetic characters or integers, or any combination of the two.
Routing:
$routes->add('/objects/(:alphanum)/(:num)', 'Admin::objectsList/$1/$2');
URL:
https://adm.domain.com/objects/users/10 - DOESN'T WORK

Routing:
$routes->add('/objects/(:alpha)/(:num)', 'Admin::objectsList/$1/$2');
URL:
https://adm.domain.com/objects/users/10 - WORKS

@iLevye
Copy link

iLevye commented May 16, 2017

i think the 'alphanum' key must be define before 'alpha' key. can you try swap 'alphanum' and 'num' keys in system/Router/RouterCollection class $placeholders property

@nowackipawel
Copy link
Contributor Author

protected $placeholders = [ 'any' => '.*', 'segment' => '[^/]+', 'alphanum' => '[a-zA-Z0-9]+', 'num' => '[0-9]+', 'alpha' => '[a-zA-Z]+', 'hash' => '[^/]+', ];

It works with that change. Anyway I needed alphanumdash so I defined my own rule :).

@nowackipawel
Copy link
Contributor Author

There is another "error" which has connection with that above... you can't create for example new rule which contain at the beginning key from $placeholders.
For ex.
$routes->addPlaceholder('alphanumdash', '([0-9a-zA-Z_\-\.]+)'); - doesn't work,
$routes->addPlaceholder('dashalphanum', '([0-9a-zA-Z_\-\.]+)'); - works well
To be honest you shouldn't treat this as error but it should be mentioned in docs ;).

@lonnieezell
Copy link
Member

Good catch with the ordering of default placeholders.

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

3 participants