Skip to content

Bug in getFragment #1

Open
Open

Description

@switz

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, '\\$&');

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions