Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

handles optional segments in uri generation #4

Merged
merged 7 commits into from
Jan 25, 2016

Conversation

pine3ree
Copy link
Contributor

Quick fix to handle routes defined with path like:

//...
'name' => 'blog/post',
'path' => '/blog/post[/{action:index|recent}[/{page:\d+}[/optional-{extra}]]]',
//...
$urlHelper('blog/post');

// assume that current matching route has action=index and page=3

// w/o fix  => blog/post[/index[/3[/optional-{extra}]]]  
// with fix => blog/post/index/3
  • TODO: add unit test case ***DONE
  • ALT: use slim-3 method (leveraging fastroute std route parser) for uri generation? ***NO
  • throw exception if substituted optional segment lives inside an unsubstituted optional segment? ***DONE
  • use regex for argument matching instead of strpos? (strpos is faster and should be enough to match opening curly brackets for acceptable fast-route paths)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants