Skip to content

Commit

Permalink
Avoid using URL.canParse (#1701)
Browse files Browse the repository at this point in the history
* Avoid using canParse

* Ignore bad url
  • Loading branch information
jamesmaa authored Dec 27, 2024
1 parent 5c409b9 commit 3fcbb92
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ext/js/data/anki-note-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@ 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 = '';
try {
const url = new URL(context.url);
if (url.protocol === new URL(import.meta.url).protocol) {
context.url = '';
}
} catch (e) {
// Ignore
}

const commonData = this._createData(dictionaryEntry, mode, context, resultOutputMode, glossaryLayoutMode, compactTags, media, dictionaryStylesMap);
Expand Down

0 comments on commit 3fcbb92

Please sign in to comment.