fix: ignore displaying undefined template error in file name
This commit is contained in:
parent
22482f5bbd
commit
45b14dfd75
2 changed files with 7 additions and 6 deletions
|
|
@ -22,11 +22,11 @@ export function replaceIllegalFileNameCharactersInString(string: string): string
|
|||
return string.replace(/[\\,#%&{}/*<>$"@.?]*/g, '').replace(/:+/g, ' -');
|
||||
}
|
||||
|
||||
export function replaceTags(template: string, mediaTypeModel: MediaTypeModel): string {
|
||||
return template.replace(new RegExp('{{.*?}}', 'g'), (match: string) => replaceTag(match, mediaTypeModel));
|
||||
export function replaceTags(template: string, mediaTypeModel: MediaTypeModel, ignoreUndefined: boolean = false): string {
|
||||
return template.replace(new RegExp('{{.*?}}', 'g'), (match: string) => replaceTag(match, mediaTypeModel, ignoreUndefined));
|
||||
}
|
||||
|
||||
function replaceTag(match: string, mediaTypeModel: MediaTypeModel): string {
|
||||
function replaceTag(match: string, mediaTypeModel: MediaTypeModel, ignoreUndefined: boolean): string {
|
||||
let tag = match;
|
||||
tag = tag.substring(2);
|
||||
tag = tag.substring(0, tag.length - 2);
|
||||
|
|
@ -39,7 +39,7 @@ function replaceTag(match: string, mediaTypeModel: MediaTypeModel): string {
|
|||
const obj = traverseMetaData(path, mediaTypeModel);
|
||||
|
||||
if (obj === undefined) {
|
||||
return '{{ INVALID TEMPLATE TAG - object undefined }}';
|
||||
return ignoreUndefined ? '' : '{{ INVALID TEMPLATE TAG - object undefined }}';
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
|
@ -51,7 +51,7 @@ function replaceTag(match: string, mediaTypeModel: MediaTypeModel): string {
|
|||
const obj = traverseMetaData(path, mediaTypeModel);
|
||||
|
||||
if (obj === undefined) {
|
||||
return '{{ INVALID TEMPLATE TAG - object undefined }}';
|
||||
return ignoreUndefined ? '' : '{{ INVALID TEMPLATE TAG - object undefined }}';
|
||||
}
|
||||
|
||||
if (operator === 'LIST') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue