From 8de5d139f94af875d6c073bf8d89107020f7a64d Mon Sep 17 00:00:00 2001 From: Tobias Ortmayr Date: Fri, 6 Dec 2024 12:32:24 +0100 Subject: [PATCH] GLSP-1441: Fix NavigationTargetResolver uri handling (#403) Normalize source and target uris by striping a potential file:// prefix before comparing Part of: https://github.com/eclipse-glsp/glsp/issues/1441 --- .../features/navigation/navigation-target-resolver.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/client/src/features/navigation/navigation-target-resolver.ts b/packages/client/src/features/navigation/navigation-target-resolver.ts index 8d7cdc428..a297f30fa 100644 --- a/packages/client/src/features/navigation/navigation-target-resolver.ts +++ b/packages/client/src/features/navigation/navigation-target-resolver.ts @@ -13,7 +13,6 @@ * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ -import { inject, injectable } from 'inversify'; import { IActionDispatcher, ILogger, @@ -23,6 +22,7 @@ import { SetResolvedNavigationTargetAction, TYPES } from '@eclipse-glsp/sprotty'; +import { inject, injectable } from 'inversify'; import { IDiagramOptions } from '../../base/model/diagram-loader'; /** @@ -51,9 +51,12 @@ export class NavigationTargetResolver { target: NavigationTarget ): Promise { const targetUri = decodeURIComponent(target.uri); - if (sourceUri && sourceUri !== targetUri && `file://${sourceUri}` !== targetUri) { + const normalizedSourceUri = sourceUri?.replace(/^file:\/\//, ''); + const normalizedTargetUri = targetUri.replace(/^file:\/\//, ''); + + if (normalizedSourceUri && normalizedSourceUri !== normalizedTargetUri) { // different URI, so we can't resolve it locally - this.logger.info("Source and Target URI are different. Can't resolve locally.", sourceUri, targetUri); + this.logger.info("Source and Target URI are different. Can't resolve locally.", normalizedSourceUri, normalizedTargetUri); return undefined; } if (NavigationTarget.getElementIds(target).length > 0) {