Skip to content

Commit

Permalink
Add empty string to field if url starts with chrome-extension or moz-…
Browse files Browse the repository at this point in the history
…extension
  • Loading branch information
dchen5022 committed Dec 21, 2024
1 parent 7372f27 commit a78eed2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ext/js/data/anki-note-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ export class AnkiNoteBuilder {
const fieldName = fields[i][0];
const {value, errors: fieldErrors, requirements: fieldRequirements} = formattedFieldValues[i];
noteFields[fieldName] = value;

// Make field blank if URL if starts with chrome-extension or moz-extension
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')) {
noteFields[fieldName] = '';
}
}

allErrors.push(...fieldErrors);
for (const requirement of fieldRequirements) {
const key = JSON.stringify(requirement);
Expand Down

0 comments on commit a78eed2

Please sign in to comment.