From 120f0af4f69bf3a1c006776a689cbc3be1e058c4 Mon Sep 17 00:00:00 2001 From: Dennis Chen <113411363+dchen5022@users.noreply.github.com> Date: Mon, 23 Dec 2024 13:51:30 -0500 Subject: [PATCH] Leave url field blank when creating cards from search page (#1685) * 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 --- 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 ccf7c225ed..7586516ada 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 Yomitan + 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) {