From f0ab159a02a4dfa53bc4d49927b53d024b89571d Mon Sep 17 00:00:00 2001 From: Michele Santoro Date: Mon, 8 Apr 2024 14:35:05 +0200 Subject: [PATCH] Remove first character on referenced Aspect Model filename --- core/libs/editor/src/lib/editor.service.ts | 9 +-------- core/libs/rdf/src/lib/services/rdf.service.ts | 5 +++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/core/libs/editor/src/lib/editor.service.ts b/core/libs/editor/src/lib/editor.service.ts index b10fb47e..90534a37 100644 --- a/core/libs/editor/src/lib/editor.service.ts +++ b/core/libs/editor/src/lib/editor.service.ts @@ -273,7 +273,7 @@ export class EditorService { loadExternalAspectModel(extRefAbsoluteAspectModelFileName: string): CachedFile { const extRdfModel = this.rdfService.externalRdfModels.find( - extRef => this.removeStartingCharacter(extRef.absoluteAspectModelFileName,'/') === extRefAbsoluteAspectModelFileName, + extRef => extRef.absoluteAspectModelFileName === extRefAbsoluteAspectModelFileName, ); const fileName = extRdfModel.aspectModelFileName; let foundCachedFile = this.namespaceCacheService.getFile([extRdfModel.getAspectModelUrn(), fileName]); @@ -285,13 +285,6 @@ export class EditorService { return foundCachedFile; } - removeStartingCharacter(value: string, character: string): string { - if (value.charAt(0) === character) { - return value.substring(1); - } - return value; - } - loadExternalModels(): Observable> { this.rdfService.externalRdfModels = []; return this.modelApiService.getAllNamespacesFilesContent().pipe( diff --git a/core/libs/rdf/src/lib/services/rdf.service.ts b/core/libs/rdf/src/lib/services/rdf.service.ts index afe9e160..b9c23886 100644 --- a/core/libs/rdf/src/lib/services/rdf.service.ts +++ b/core/libs/rdf/src/lib/services/rdf.service.ts @@ -165,12 +165,13 @@ export class RdfService { return subject; } - parseFileName(fileName: string, urn: string): string { + private parseFileName(fileName: string, urn: string): string { if (this.browserService.isStartedAsElectronApp()) { const path = window.require('path'); fileName = fileName.includes(path.sep) ? `${urn.replace('#', ':')}${path.basename(fileName)}` : fileName; } - return fileName; + + return fileName.charAt(0) === '/' ? fileName.substring(1) : fileName; } parseModels(fileContentModels: FileContentModel[]): Observable {