Remove backslash from search queries
Co-authored-by: Lee Randy <randy.lee@metronom.com> Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> See [#5053][0]. [0]: https://github.com/signalapp/Signal-Desktop/pull/5053
This commit is contained in:
parent
901a54b149
commit
8b51f174d8
2 changed files with 14 additions and 1 deletions
13
ts/test-both/util/cleanSearchTerm_test.ts
Normal file
13
ts/test-both/util/cleanSearchTerm_test.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { cleanSearchTerm } from '../../util/cleanSearchTerm';
|
||||
|
||||
describe('cleanSearchTerm', () => {
|
||||
it('should remove \\ from a search term', () => {
|
||||
const searchTerm = '\\search\\term';
|
||||
const sanitizedSearchTerm = cleanSearchTerm(searchTerm);
|
||||
assert.strictEqual(sanitizedSearchTerm, 'search* term*');
|
||||
});
|
||||
});
|
|
@ -4,7 +4,7 @@
|
|||
export function cleanSearchTerm(searchTerm: string): string {
|
||||
const lowercase = searchTerm.toLowerCase();
|
||||
const withoutSpecialCharacters = lowercase.replace(
|
||||
/([!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~])/g,
|
||||
/([-!"#$%&'()*+,./\\:;<=>?@[\]^_`{|}~])/g,
|
||||
' '
|
||||
);
|
||||
const whiteSpaceNormalized = withoutSpecialCharacters.replace(/\s+/g, ' ');
|
||||
|
|
Loading…
Reference in a new issue