Skip to content

fix(recent-searches): escape highlighted query regex#387

Merged
shortcuts merged 4 commits intonextfrom
fix/recent-searches
Jan 12, 2021
Merged

fix(recent-searches): escape highlighted query regex#387
shortcuts merged 4 commits intonextfrom
fix/recent-searches

Conversation

@shortcuts
Copy link
Copy Markdown
Member

Summary
The previous RegEx was not escaping parentheses or question marks in recent searches.

Actual behavior

  • Parentheses: Throw an error when a parenthesis is typed invalid regex
  • Question marks: Duplicates the question mark when it's typed (e.g. with query Amazon? result is Amazon??)
    and then throwing error while trying to replace the `item.query

@shortcuts shortcuts requested a review from Haroenv January 5, 2021 13:19
@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci bot commented Jan 5, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9276504:

Sandbox Source
@algolia/js-example Configuration
@algolia/react-renderer-example Configuration

Copy link
Copy Markdown
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the replaceAll option is more suitable, since it can be polyfilled

@shortcuts
Copy link
Copy Markdown
Member Author

shortcuts commented Jan 5, 2021

waiting for @francoischalifour's opinion before merging

@shortcuts shortcuts changed the title fix(recent-searches): Replace regex with replaceAll fix(recent-searches): escape highlighted query regex Jan 11, 2021
Copy link
Copy Markdown
Contributor

@francoischalifour francoischalifour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch—thank you!

@shortcuts shortcuts merged commit d23f133 into next Jan 12, 2021
@shortcuts shortcuts deleted the fix/recent-searches branch January 12, 2021 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants