Clean up generated files names to remove or replace invalid characters
This commit is contained in:
parent
9fa7348ae9
commit
9a702b6fc7
1 changed files with 7 additions and 1 deletions
|
|
@ -71,7 +71,13 @@ export class MediaTypeManager {
|
||||||
|
|
||||||
getFileName(mediaTypeModel: MediaTypeModel): string {
|
getFileName(mediaTypeModel: MediaTypeModel): string {
|
||||||
// Ignore undefined tags since some search APIs do not return all properties in the model and produce clean file names even if errors occur
|
// Ignore undefined tags since some search APIs do not return all properties in the model and produce clean file names even if errors occur
|
||||||
return replaceTags(this.mediaFileNameTemplateMap.get(mediaTypeModel.getMediaType())!, mediaTypeModel, true);
|
let fileName = replaceTags(this.mediaFileNameTemplateMap.get(mediaTypeModel.getMediaType())!, mediaTypeModel, true);
|
||||||
|
return this.cleanFileName(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanFileName(fileName: string) {
|
||||||
|
const invalidCharsRegex = /\™|\®|,|#|\[|\]|\||\^|\<|\>|\?|\*|\\|\//g;
|
||||||
|
return fileName.replaceAll(invalidCharsRegex, '').replaceAll(/"/g, "'").replaceAll(/:/g, ' -');
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTemplate(mediaTypeModel: MediaTypeModel, app: App): Promise<string> {
|
async getTemplate(mediaTypeModel: MediaTypeModel, app: App): Promise<string> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue