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

Routes with Non Participating Capture Groups exec() differently in old IE browsers #1076

Closed
ericf opened this issue Aug 12, 2013 · 1 comment
Assignees
Labels

Comments

@ericf
Copy link
Member

ericf commented Aug 12, 2013

We recently fixed issue #964 to support Non Participating Capture Groups (NPCG) in regex Router paths. But the tests for this change were not run in IE < 9, and when they are subtle differences are surfaced in how old IEs vs. modern browsers deal with NPCG when calling the regex's exec() method. The following example illustrates the issue:

var route = /\/foo\/(bar)?/;

// In modern browsers:
console.log(route.exec('/foo/')); // => ["/foo/", undefined]

// In IE < 9:
console.log(route.exec('/foo/')); // => ["/foo/", ""]

In the context of route dispatching in Router, the result of exec()-ing the regex route path is assigned to req.params. Since request parameters are dealing with strings, I think a fine compromise is to always make sure they are an array of strings and coerce undefined to empty string, both are falsy values.

@ghost ghost assigned ericf Aug 12, 2013
@evocateur
Copy link
Contributor

+1

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

No branches or pull requests

2 participants