8000 [Routing] Fix the matching process by vicb · Pull Request #4139 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Routing] Fix the matching process #4139

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

Closed
wants to merge 2 commits into from
Closed

Conversation

vicb
Copy link
Contributor
@vicb vicb commented Apr 27, 2012

This PR is based on the PR #3678.
Build Status

The spec

A pattern is composed of both text and variable segments: /{variable}-test/{other_variable}.

A variable segment will match anything until a separator is encountered. The separator is the character following the variable segment when available or preceding the variable otherwise (i.e. at the end of the pattern).

That is:

  • the separator is - for the variable,
  • the separator is / for the other_variable.

Note: This default matching behavior can be overridden if a requirement is specified for a variable)

Fixes

  • The current behavior is to consider booth the preceding and following characters as separators (considering availability),
  • The "preceding" separator of the first variable is always set to / whatever the preceding character is (due to $pos = 0 for the first iteration).

Todo

Update the doc once this is merged

@Tobion
Copy link
Contributor
Tobion commented Apr 27, 2012

Your using the wrong slash (\) in the description.

@vicb
Copy link
Contributor Author
vicb commented Apr 27, 2012

@Tobion fixed, thanks.

@dlsniper
Copy link
Contributor

@vicb Does your fix also take into account: /{variable}-test/{other_variable}/ case?

Thanks

@vicb
Copy link
Contributor Author
vicb commented Apr 30, 2012

@dlsniper in your example the separator for the other_variable would be / (the trailing slash). Does that answer your question ?

@dlsniper
Copy link
Contributor

@vicb yes, that's what I mean.

Currently I have something like your example but I want to have the {other_variable} optional. If I make that, then I'm in a world of trouble as the router won't match the route /{variable}-test/. This is a bit of my original question but I hope you can understand what I'm trying to describe.

Thanks.

P.S. when will this be merged?

@vicb
Copy link
Contributor Author
vicb commented May 1, 2012

@dlsniper this PR only fixes the choice of a separator, the matching process is left unchanged, i.e. the behavior will be the same when a variable in the last position is optional and followed by a separator.

Closing to submit against the master branch.

@vicb vicb closed this May 1, 2012
fabpot added a commit that referenced this pull request May 7, 2012
Commits
-------

a196ca0 [Routing] Compiler: remove lazy quantifiers with no effect
8232aa1 [Routing] Compiler: fix in the computing of the segment separators

Discussion
----------

[Routing] Fix the matching process

This PR is based on the PR #3678, #4139.

[![Build Status](https://secure.travis-ci.org/vicb/symfony.png?branch=routingmatcher)](http://travis-ci.org/vicb/symfony)

**The spec**

A pattern is composed of both text and variable segments: `/{variable}-test/{other_variable}`.

A variable segment will match anything until a separator is encountered. The separator is the character following the variable segment when available or preceding the variable otherwise (i.e. at the end of the pattern).

That is:

* the separator is `-` for the `variable`,
* the separator is `/` for the `other_variable`.

*Note: This default matching behavior can be overridden if a requirement is specified for a variable)*

**Fixes**

* The current behavior is to consider booth the preceding and following characters as separators (considering availability),
* The "preceding" separator of the first variable is always set to `/` whatever the preceding character is (due to `$pos = 0` for the first iteration).

**Todo**

Update the doc once this is merged
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

Successfully merging this pull request may close these issues.

3 participants
0