From bd119c9b4543aaf0be05588cf4c8b9f6c25b6db5 Mon Sep 17 00:00:00 2001 From: Kilian Seizinger <56249171+pri-kise@users.noreply.github.com> Date: Fri, 20 Dec 2024 12:43:56 +0100 Subject: [PATCH] Add Affix Check for Object Name (#314) --- src/NAVObject.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/NAVObject.ts b/src/NAVObject.ts index ad57e0a3..840276e4 100644 --- a/src/NAVObject.ts +++ b/src/NAVObject.ts @@ -410,7 +410,23 @@ export class NAVObject { private AddPrefixAndSuffixToObjectNameFixed(objectName: string): string { let prefix = this._workSpaceSettings[Settings.ObjectNamePrefix]; let suffix = this._workSpaceSettings[Settings.ObjectNameSuffix]; - if (!prefix && !suffix) { return objectName } + let affixes = this._workSpaceSettings[Settings.MandatoryAffixes]; + let affixesDefined = Array.isArray(affixes) && (affixes.length > 0); + + if (!prefix && !suffix && !affixesDefined) { return objectName } + + if (affixesDefined) { + var affixNeeded = true; + affixes.forEach((affix: string) => { + if (objectName.startsWith(affix) || objectName.endsWith(affix)) { + affixNeeded = false; + return + } + }); + if (!affixNeeded) { + return objectName; + } + } if (prefix && !objectName.startsWith(prefix)) { objectName = prefix + objectName;