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

RFC: Changing 'searchPlaceholder' regex in urlMatcherFactory #2402

Closed
SmilingJoe opened this issue Nov 30, 2015 · 1 comment
Closed

RFC: Changing 'searchPlaceholder' regex in urlMatcherFactory #2402

SmilingJoe opened this issue Nov 30, 2015 · 1 comment

Comments

@SmilingJoe
Copy link

This regards version 0.2.15 of ui-router.

With details specified in this issue, I would like to suggest changing the regular expression assigned to the variable 'searchPlaceholder' in urlMatcherFactory, so that url query parameters containing periods are correctly routed.

So instead of just the character set \w\[\]- begin considered valid, \w\[\].- would now be considered as valid. My original thought was to include a wider range of possible valid characters, however thinking now that this should be modified on an 'as needed' basis?

This change would modify:

searchPlaceholder = /([:]?)([\w\[\]-]+)|\{([\w\[\]-]+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,

to be:

searchPlaceholder = /([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,

Not sure if this should effect the 'placeholder' variable as well, however for my current problem just modifying 'searchPlaceholder' appears to resolve the issue.

Update:

After making this change locally, I noticed that I was getting an invalid parameter exception from the regex inside of the 'addParameter' function:

if (!/^\w+(-+\w+)*(?:\[\])?$/.test(id)) throw new Error("Invalid parameter name '" + id + "' in pattern '" + pattern + "'");

After testing a couple of different options, it seems like this modification would allow for periods inside of a parameter name to work as well:

if (!/^\w+([-.]+\w+)*(?:\[\])?$/.test(id)) throw new Error("Invalid parameter name '" + id + "' in pattern '" + pattern + "'");

So this change would include this modification as well.

@eddiemonge
Copy link
Contributor

Marking this as a duplicate since you already have that other issue open.

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

No branches or pull requests

2 participants