Skip to content

Commit

Permalink
Leave url field blank when creating cards from search page (#1685)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dchen5022 authored Dec 23, 2024
1 parent 7372f27 commit 120f0af
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/js/data/anki-note-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 120f0af

Please sign in to comment.