Skip to content

Commit

Permalink
Check for external protocl value instead
Browse files Browse the repository at this point in the history
  • Loading branch information
dchen5022 committed Dec 21, 2024
1 parent a78eed2 commit 12b5918
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/js/data/anki-note-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ export class AnkiNoteBuilder {
const {value, errors: fieldErrors, requirements: fieldRequirements} = formattedFieldValues[i];
noteFields[fieldName] = value;

// Make field blank if URL if starts with chrome-extension or moz-extension
// Make URL field blank if URL source is Yomitan
const internalFieldName = fields[i][1];
if (internalFieldName === '{url}') {
const urlPrefix = '<a href="';
const url = value.replace(urlPrefix, '');
if (url.startsWith('chrome-extension') || url.startsWith('moz-extension')) {
if (!['http:', 'https:', 'ws:', 'wss:', 'ftp:', 'data:', 'file:'].includes(new URL(url).protocol)) {
noteFields[fieldName] = '';
}
}
Expand Down

0 comments on commit 12b5918

Please sign in to comment.