1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

All: Better handle search queries that include dashes

This commit is contained in:
Laurent Cozic 2019-01-31 08:35:41 +00:00
parent 9e165fc7dc
commit 8c9a148e71
2 changed files with 23 additions and 0 deletions

View File

@ -254,4 +254,26 @@ describe('services_SearchEngine', function() {
expect(engine.parseQuery('*').termCount).toBe(0); expect(engine.parseQuery('*').termCount).toBe(0);
})); }));
it('should handle queries with special characters', asyncTest(async () => {
let rows;
const testCases = [
['did-not-match', 'did-not-match'],
['does match', 'does match'],
];
for (let i = 0; i < testCases.length; i++) {
const t = testCases[i];
const content = t[0];
const query = t[1];
const n = await Note.save({ title: content });
await engine.syncTables();
rows = await engine.search(query);
expect(rows.length).toBe(1);
await Note.delete(n.id);
}
}));
}); });

View File

@ -355,6 +355,7 @@ class SearchEngine {
async search(query) { async search(query) {
query = this.normalizeText_(query); query = this.normalizeText_(query);
query = query.replace(/-/g, ' '); // https://github.com/laurent22/joplin/issues/1075#issuecomment-459258856
const st = scriptType(query); const st = scriptType(query);