Skip to content

Commit

Permalink
Leave url field blank when creating cards from search page
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

<rikaitan.link>MTIwZjBhZjRmNjliZjNhMWMwMDY3NzZhNjg5Y2JjM2JlMWUwNThjNAo=</rikaitan.link>
  • Loading branch information
jason-ojisan committed Dec 24, 2024
1 parent ac927d8 commit c24e8ec
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 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) {
Expand Down

0 comments on commit c24e8ec

Please sign in to comment.