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

Support array paths with parameter name collisions #27

Merged
merged 2 commits into from
Jun 24, 2015

Conversation

gigabo
Copy link
Contributor

@gigabo gigabo commented Jun 24, 2015

Example:

path: [
    '/a/:foo/:bar',
    '/b/:bar'
]

Previously the bar parameter would only be populated for the /b/ path.

With this patch it will be populated regardless of which path matches.

Thanks!

Example:

```
path: [
    '/a/:foo/:bar',
    '/b/:bar'
]
```

Previously the `bar` parameter would only be populated for the `/b/` path.

With this patch it will be populated regardless of which path matches.
@yahoocla
Copy link

CLA is valid!

@Vijar Vijar added the ready label Jun 24, 2015
// Don't overwrite a previously populated parameter with `undefined`.
// A route may legitimately have multiple instances of a parameter
// name if the path was an array.
if (pathMatches[i+1] !== void 0 || routeParams[self.keys[i].name] === void 0){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: instead of void 0, could you use undefined to be consistent with rest of code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You got it. Thanks!

@lingyan
Copy link
Member

lingyan commented Jun 24, 2015

@gigabo Thanks for fixing this! Left a minor comment, then we'll be ready to go.

Per feedback in pull request.
lingyan added a commit that referenced this pull request Jun 24, 2015
Support array paths with parameter name collisions
@lingyan lingyan merged commit 1d2a89b into yahoo:master Jun 24, 2015
@lingyan lingyan removed the ready label Jun 24, 2015
@lingyan
Copy link
Member

lingyan commented Jun 24, 2015

@gigabo Thanks for your contribution! This fix has been released in https://github.com/yahoo/routr/releases/tag/v0.1.3

gigabo added a commit to redfin/react-server that referenced this pull request Feb 9, 2016
This picks up [my PR](yahoo/routr#27), and addresses RED-66130.
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.

None yet

4 participants