-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Can ui-router handle periods in url query parameter names? #2395
Comments
After educating myself some on regular expressions, and then tracing the execution path of ui-router, I think I've narrowed down where this is occurring in the code, along with a possible fix. Inside of angular-ui-router.js (v0.2.15), in the file urlMatcherFactory.js the variable searchPlaceholder is defined as follows:
Lower down is where any search parameters get processed by the following section of code:
If I replace the The final modified regular expression that seems to include periods as valid characters is:
Now I'm far from an expert in regular expressions, so there may be a better way to resolve that. As well, there might be another way altogether that is already part of the framework that I'm just not seeing. If so, please let me know. |
Is the behavior the same if you define the params in a |
Also, can you write a failing/passing test for this? |
Hello, Sorry for the delayed response. So as far as using the I will write up the tests tomorrow for the proposed update I have. |
Hello Eddie, Here is the test coverage I've added to the urlMatcherFactorySpec.js file. After running grunt against the latest modified repo, I see that 316 test complete successfully. Is this sufficient?
|
…ontain periods This change modifies the searchPlaceholder regex to include the period character as valid for url query param names. This change also modifies the regex found in the addParameter function which validates the param name just prior to adding to the list of parameters. A new set of unit tests were added to urlMatcherFactorySpec to ensure this modification works correctly. This change resolves issue angular-ui#2395
…ontain periods This change modifies the searchPlaceholder regex to include the period character as valid for url query param names. This change also modifies the regex found in the addParameter function which validates the param name just prior to adding to the list of parameters. A new set of unit tests were added to urlMatcherFactorySpec to ensure this modification works correctly. This change resolves issue angular-ui#2395
…ontain periods This change modifies the searchPlaceholder regex to include the period character as valid for url query param names. This change also modifies the regex found in the addParameter function which validates the param name just prior to adding to the list of parameters. A new set of unit tests were added to urlMatcherFactorySpec to ensure this modification works correctly. This change resolves issue #2395
Looks like this got resolved in d31b333 |
…ontain periods This change modifies the searchPlaceholder regex to include the period character as valid for url query param names. This change also modifies the regex found in the addParameter function which validates the param name just prior to adding to the list of parameters. A new set of unit tests were added to urlMatcherFactorySpec to ensure this modification works correctly. This change resolves issue angular-ui#2395
Using ui-router v0.2.15. Have a route in our AngularJS (v1.4.7) application setup as follows:
As I understand the protocol, having periods inside of url query parameter names is valid. i.e.;
When I setup this route in Angular, I get an error because the regex appears to be stripping out (or splitting up) the name portion into segments. So it essentially sees 'param.sub.a' as just 'param', and then errors out stating that 'param.sub.b' is a duplicate of 'param.sub.a' (because it only reads the 'param' portion of 'param.sub.b').
Unfortunately, we cannot change the parameter names as they are part of an existing protocol.
Is there a workaround to this issue? Hoping that I'm just missing something obvious already existing in the framework that can resolve this problem.
The text was updated successfully, but these errors were encountered: