diff --git a/src/becca/entities/battribute.ts b/src/becca/entities/battribute.ts index 97df7b056..66ef83ca8 100644 --- a/src/becca/entities/battribute.ts +++ b/src/becca/entities/battribute.ts @@ -174,7 +174,7 @@ class BAttribute extends AbstractBeccaEntity { this.validate(); } - this.name = sanitizeAttributeName.sanitizeAttributeName(this.name); + this.name = sanitizeAttributeName(this.name); if (!this.value) { // null value isn't allowed diff --git a/src/routes/api/sender.ts b/src/routes/api/sender.ts index 22eea766d..705cac25e 100644 --- a/src/routes/api/sender.ts +++ b/src/routes/api/sender.ts @@ -3,7 +3,7 @@ import imageType from "image-type"; import imageService from "../../services/image.js"; import noteService from "../../services/notes.js"; -import sanitize_attribute_name from "../../services/sanitize_attribute_name.js"; +import sanitizeAttributeName from "../../services/sanitize_attribute_name.js"; import specialNotesService from "../../services/special_notes.js"; import { Request } from 'express'; @@ -44,7 +44,7 @@ async function uploadImage(req: Request) { const labels = JSON.parse(labelsStr); for (const { name, value } of labels) { - note.setLabel(sanitize_attribute_name.sanitizeAttributeName(name), value); + note.setLabel(sanitizeAttributeName(name), value); } } @@ -73,7 +73,7 @@ function saveNote(req: Request) { if (req.body.labels) { for (const { name, value } of req.body.labels) { - note.setLabel(sanitize_attribute_name.sanitizeAttributeName(name), value); + note.setLabel(sanitizeAttributeName(name), value); } } diff --git a/src/services/consistency_checks.ts b/src/services/consistency_checks.ts index fe37c7c15..fa1cec21d 100644 --- a/src/services/consistency_checks.ts +++ b/src/services/consistency_checks.ts @@ -754,7 +754,7 @@ class ConsistencyChecks { const attrNames = sql.getColumn(`SELECT DISTINCT name FROM attributes`); for (const origName of attrNames) { - const fixedName = sanitizeAttributeName.sanitizeAttributeName(origName); + const fixedName = sanitizeAttributeName(origName); if (fixedName !== origName) { if (this.autoFix) { diff --git a/src/services/import/enex.ts b/src/services/import/enex.ts index 071b66cdb..f0805b2fc 100644 --- a/src/services/import/enex.ts +++ b/src/services/import/enex.ts @@ -151,7 +151,7 @@ function importEnex(taskContext: TaskContext, file: File, parentNote: BNote): Pr labelName = 'pageUrl'; } - labelName = sanitizeAttributeName.sanitizeAttributeName(labelName || ""); + labelName = sanitizeAttributeName(labelName || ""); if (note.attributes) { note.attributes.push({ @@ -202,7 +202,7 @@ function importEnex(taskContext: TaskContext, file: File, parentNote: BNote): Pr } else if (currentTag === 'tag' && note.attributes) { note.attributes.push({ type: 'label', - name: sanitizeAttributeName.sanitizeAttributeName(text), + name: sanitizeAttributeName(text), value: '' }) } diff --git a/src/services/sanitize_attribute_name.ts b/src/services/sanitize_attribute_name.ts index 635588f80..075ccfd03 100644 --- a/src/services/sanitize_attribute_name.ts +++ b/src/services/sanitize_attribute_name.ts @@ -1,4 +1,4 @@ -function sanitizeAttributeName(origName: string) { +export default function sanitizeAttributeName(origName: string) { let fixedName: string; if (origName === '') { @@ -10,9 +10,4 @@ function sanitizeAttributeName(origName: string) { } return fixedName; -} - - -export default { - sanitizeAttributeName -}; +} \ No newline at end of file