mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 19:49:01 +01:00 
			
		
		
		
	refactor(sanitizeAttributeNames): directly export function
no need to wrap the exported function in an object first
This commit is contained in:
		
							parent
							
								
									2556d51870
								
							
						
					
					
						commit
						afb91f82e1
					
				| @ -174,7 +174,7 @@ class BAttribute extends AbstractBeccaEntity<BAttribute> { | |||||||
|             this.validate(); |             this.validate(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         this.name = sanitizeAttributeName.sanitizeAttributeName(this.name); |         this.name = sanitizeAttributeName(this.name); | ||||||
| 
 | 
 | ||||||
|         if (!this.value) { |         if (!this.value) { | ||||||
|             // null value isn't allowed
 |             // null value isn't allowed
 | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ | |||||||
| import imageType from "image-type"; | import imageType from "image-type"; | ||||||
| import imageService from "../../services/image.js"; | import imageService from "../../services/image.js"; | ||||||
| import noteService from "../../services/notes.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 specialNotesService from "../../services/special_notes.js"; | ||||||
| import { Request } from 'express'; | import { Request } from 'express'; | ||||||
| 
 | 
 | ||||||
| @ -44,7 +44,7 @@ async function uploadImage(req: Request) { | |||||||
|         const labels = JSON.parse(labelsStr); |         const labels = JSON.parse(labelsStr); | ||||||
| 
 | 
 | ||||||
|         for (const { name, value } of labels) { |         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) { |     if (req.body.labels) { | ||||||
|         for (const { name, value } of req.body.labels) { |         for (const { name, value } of req.body.labels) { | ||||||
|             note.setLabel(sanitize_attribute_name.sanitizeAttributeName(name), value); |             note.setLabel(sanitizeAttributeName(name), value); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -754,7 +754,7 @@ class ConsistencyChecks { | |||||||
|         const attrNames = sql.getColumn<string>(`SELECT DISTINCT name FROM attributes`); |         const attrNames = sql.getColumn<string>(`SELECT DISTINCT name FROM attributes`); | ||||||
| 
 | 
 | ||||||
|         for (const origName of attrNames) { |         for (const origName of attrNames) { | ||||||
|             const fixedName = sanitizeAttributeName.sanitizeAttributeName(origName); |             const fixedName = sanitizeAttributeName(origName); | ||||||
| 
 | 
 | ||||||
|             if (fixedName !== origName) { |             if (fixedName !== origName) { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|  | |||||||
| @ -151,7 +151,7 @@ function importEnex(taskContext: TaskContext, file: File, parentNote: BNote): Pr | |||||||
|                 labelName = 'pageUrl'; |                 labelName = 'pageUrl'; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             labelName = sanitizeAttributeName.sanitizeAttributeName(labelName || ""); |             labelName = sanitizeAttributeName(labelName || ""); | ||||||
| 
 | 
 | ||||||
|             if (note.attributes) { |             if (note.attributes) { | ||||||
|                 note.attributes.push({ |                 note.attributes.push({ | ||||||
| @ -202,7 +202,7 @@ function importEnex(taskContext: TaskContext, file: File, parentNote: BNote): Pr | |||||||
|             } else if (currentTag === 'tag' && note.attributes) { |             } else if (currentTag === 'tag' && note.attributes) { | ||||||
|                 note.attributes.push({ |                 note.attributes.push({ | ||||||
|                     type: 'label', |                     type: 'label', | ||||||
|                     name: sanitizeAttributeName.sanitizeAttributeName(text), |                     name: sanitizeAttributeName(text), | ||||||
|                     value: '' |                     value: '' | ||||||
|                 }) |                 }) | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| function sanitizeAttributeName(origName: string) { | export default function sanitizeAttributeName(origName: string) { | ||||||
|     let fixedName: string; |     let fixedName: string; | ||||||
| 
 | 
 | ||||||
|     if (origName === '') { |     if (origName === '') { | ||||||
| @ -11,8 +11,3 @@ function sanitizeAttributeName(origName: string) { | |||||||
| 
 | 
 | ||||||
|     return fixedName; |     return fixedName; | ||||||
| } | } | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| export default { |  | ||||||
|     sanitizeAttributeName |  | ||||||
| }; |  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Panagiotis Papadopoulos
						Panagiotis Papadopoulos