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: escape regexp from query #2273

Merged
merged 2 commits into from
Aug 28, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: escape regexp from query
  • Loading branch information
fengkx committed Aug 25, 2020
commit 22a16e736c8f0e50df5c8f598944caf1f9096d9e
4 changes: 2 additions & 2 deletions js/src/forum/components/DiscussionListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import DiscussionControls from '../utils/DiscussionControls';
import slidable from '../utils/slidable';
import extractText from '../../common/utils/extractText';
import classList from '../../common/utils/classList';

import { escapeRegExp } from 'lodash-es';
/**
fengkx marked this conversation as resolved.
Show resolved Hide resolved
* The `DiscussionListItem` component shows a single discussion in the
* discussion list.
Expand Down Expand Up @@ -72,7 +72,7 @@ export default class DiscussionListItem extends Component {
jumpTo = post.number();
}

const phrase = this.props.params.q;
const phrase = escapeRegExp(this.props.params.q);
this.highlightRegExp = new RegExp(phrase + '|' + phrase.trim().replace(/\s+/g, '|'), 'gi');
} else {
jumpTo = Math.min(discussion.lastPostNumber(), (discussion.lastReadPostNumber() || 0) + 1);
Expand Down