mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
core: escape paranthesis in notes search query
Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
@@ -139,3 +139,18 @@ test("search reminders", () =>
|
|||||||
const descriptionSearch = await db.lookup.reminders("please do").ids();
|
const descriptionSearch = await db.lookup.reminders("please do").ids();
|
||||||
expect(descriptionSearch).toHaveLength(1);
|
expect(descriptionSearch).toHaveLength(1);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
describe("notesWithHighlighting", () => {
|
||||||
|
test.only("search notes with parentheses in query should load the item", () =>
|
||||||
|
noteTest({
|
||||||
|
title: "(with parantheses)"
|
||||||
|
}).then(async ({ db }) => {
|
||||||
|
await db.notes.add(TEST_NOTE);
|
||||||
|
const filtered = await db.lookup.notesWithHighlighting(
|
||||||
|
"(with parantheses)",
|
||||||
|
db.notes.all
|
||||||
|
);
|
||||||
|
const item = await filtered.item(0);
|
||||||
|
expect(item.item).toBeDefined();
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|||||||
@@ -1154,7 +1154,8 @@ function textContainsTokens(text: string, tokens: QueryTokens) {
|
|||||||
const lowerCasedText = text.toLowerCase();
|
const lowerCasedText = text.toLowerCase();
|
||||||
|
|
||||||
const createTagPattern = (token: string) => {
|
const createTagPattern = (token: string) => {
|
||||||
return `<${MATCH_TAG_NAME}\\s+id="(.+?)">${token}<\\/${MATCH_TAG_NAME}>`;
|
const escapedToken = token.replace(/[()]/g, "\\$&");
|
||||||
|
return `<${MATCH_TAG_NAME}\\s+id="(.+?)">${escapedToken}<\\/${MATCH_TAG_NAME}>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user