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
Implemented bracketed optional parameters #35
Conversation
|
BTW, the code coverage remains 100% |
|
@adrianmiu Thank you. @pmjones will check and respond. |
| $this->assertTrue($foo->isMatch('/blog/archive/2014/01', array())); | ||
|
|
||
| $this->assertEquals( | ||
| [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
short array, will not get passed in 5.3 .
|
So I have talked with @pmjones regarding this. Please have a look into the discussion logs at http://colabti.org/irclogger/irclogger_log/auraphp?date=2014-01-30#l53 . Thanks |
|
From the discussion it seems the problem is the array short notation from the
|
|
So, the issue of notation stems from the (admittedly non-accepted) RFC on URI templates. This comes from the fact that we already have an "optional" notation in the form of If we expand on that idea, the "required" notation for a required param would be {foo}, "optional" for a slash-prefixed param would be {/foo}, and "optional" for a dot-prefixed param would be {.foo}. Whether that's the right thing to do or not is still a matter for discussion, but I do think it bears discussing. Update: your point regarding "You can have |
|
Tell you what @adrianmiu -- fix the short-array stuff so it passes on 5.3, and I can merge it manually to play around with it. Then we can follow up after that. (FWIW I do see the value of the patch.) |
|
I've made the required changes for 5.3.
which seem that are not very useful for optional parameters like the language. Except thigns like I do like the fact that the |
|
I think it's worth repeating one more thing related to the optional parameters that I've implemented in my code: optional parameters that have the default value are not included when generating the URL. This is very useful for SEO purposes since it will let you make a 301 redirect from I can't think of a solution to do that if you follow the RFC, even you find a way to use the RFC for matching. |
|
@pmjones this is a long time PR which needs you . |
|
I'm sorry, man, but after letting this percolate it just doesn't sit well with me, at least not for now. |
This allows one to create routes like
[/{language}]/pages[.{type}]which will match/pagesand/en/pagesand/en/pages.jsonposts/archive[/{year}][/{month}][/{day}]The
generate()method makes sure that parameters that have the default value are not included. So, if thelanguagedefault value is en the URL that will be generated will NOT start with /en