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

Bug in Moor::parseUrl #13

Open
calendee opened this issue Jan 23, 2011 · 0 comments
Open

Bug in Moor::parseUrl #13

calendee opened this issue Jan 23, 2011 · 0 comments

Comments

@calendee
Copy link

There appears to be a bug in Moor.php parseUrl().

If I define a route that has 2 request parameters that start with the same string, Moor will fail to route properly.

Examples :

Moor::route('/:api/:model/:practices_id/:model_id/', function()             // This fails

Moor::route('/:api/:model/:practices_id(\d+)/:models_id(\d+)/', function()          // This fails

Moor::route('/:api/:model/:practices_id(\d+)/:the_models_id(\d+)/', function()      // This works!!!!

Notice how the second parameter for all of these is ":model". In the first 2 examples, the 4th parameter starts with ":model". Each of these instances will cause moor to not route. In the third example, the 4th paraments contains "model" but it does not START with "model". Because of this, the fourth example routes properly.

If I dump the $url object in parseUrl(), I get the following "pattern" when the 2nd and 4th paraments contain "model":

 [pattern] => #^/(?P<api>[a-zA-Z_0-9\._]+)/(?P<model>[a-zA-Z_0-9\._]+)/(?P<practices_id>[a-zA-Z_0-9\._]+)/(?P<model>[a-zA-Z_0-9\._]+)_id/$#

Notice how the [pattern] property has replaced my "model_id" with just "model" in the 4th parameter? This of course conflicts with the first instance of "model" in the 2nd parameter.

For now, the work around is to know have any parameter names that start with the same letters.

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

1 participant