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

Bug in getFragment #1

Open
switz opened this issue Sep 23, 2014 · 0 comments
Open

Bug in getFragment #1

switz opened this issue Sep 23, 2014 · 0 comments

Comments

@switz
Copy link

switz commented Sep 23, 2014

url: search?q=ben%27s

if query has an apostrophe in it, this breaks, for example:

query => ?q=ben%27s
queryRegExp => \?q=ben%27s
      // Add the query string, if not already present
      if (query && !fragment.match(queryRegExp)) {
        fragment += query;
      }

This passes the test above and leads to fragment being doubled over, returning:

fragment => search?q=ben's?q=ben%27s 

You should decode the query before crafting a regex:

decodeURIComponent(query).replace(escapeRegExp, '\\$&');
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

No branches or pull requests

1 participant