Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug in Moor::parseUrl #13

Open
calendee opened this Issue · 0 comments

1 participant

Justin Noel
Justin Noel

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
Something went wrong with that request. Please try again.