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

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

Merged
merged 4 commits into from
Jan 12, 2021

Conversation

shortcuts
Copy link
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

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
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
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
Member

@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.

None yet

3 participants