From c24e8ec25f8f7732b95d179865d90a7e7c54ac9f Mon Sep 17 00:00:00 2001 From: Jason Ojisan Date: Mon, 23 Dec 2024 13:51:30 -0500 Subject: [PATCH] Leave url field blank when creating cards from search page * Add empty string to field if url starts with chrome-extension or moz-extension * Check for external protocl value instead * Change url field in unit tests to empty string * Check if url protocl matches window's protocol * Fix unit tests * Use slice instead of replaceAll * Remove url from context before rendering templates MTIwZjBhZjRmNjliZjNhMWMwMDY3NzZhNjg5Y2JjM2JlMWUwNThjNAo= --- ext/js/data/anki-note-builder.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js index eb59421c26..f7a37b00c7 100644 --- a/ext/js/data/anki-note-builder.js +++ b/ext/js/data/anki-note-builder.js @@ -81,6 +81,11 @@ export class AnkiNoteBuilder { } } + // Make URL field blank if URL source is Rikaitan + if (URL.canParse(context.url) && new URL(context.url).protocol === new URL(import.meta.url).protocol) { + context.url = ''; + } + const commonData = this._createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, media, dictionaryStylesMap); const formattedFieldValuePromises = []; for (const [, fieldValue] of fields) {