From 98aedec7fd91acf4edd6915d04fead15e8ccfc6c Mon Sep 17 00:00:00 2001 From: wangxinyu Date: Tue, 9 Sep 2025 09:48:54 +0800 Subject: [PATCH] title: add absolute path check Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/ICWTLV Signed-off-by: wangxinyu Change-Id: I2e66e1dcc7ffacf85358b405b5310982431defd6 --- compiler/src/interop/src/utils.ts | 2 +- compiler/src/utils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/interop/src/utils.ts b/compiler/src/interop/src/utils.ts index 7b0a287a9..247f74696 100644 --- a/compiler/src/interop/src/utils.ts +++ b/compiler/src/interop/src/utils.ts @@ -1303,7 +1303,7 @@ export function removeDecorator(decorators: readonly ts.Decorator[], decoratorNa export function isFileInProject(filePath: string, projectRootPath: string): boolean { const relativeFilePath: string = toUnixPath(path.relative(toUnixPath(projectRootPath), toUnixPath(filePath))); // When processing ohmurl, hsp's filePath is consistent with moduleRequest - return fs.existsSync(filePath) && fs.statSync(filePath).isFile() && !relativeFilePath.startsWith('../'); + return path.isAbsolute(filePath) && fs.existsSync(filePath) && fs.statSync(filePath).isFile() && !relativeFilePath.startsWith('../'); } export function getProjectRootPath(filePath: string, projectConfig: Object, rootPathSet: Object): string { diff --git a/compiler/src/utils.ts b/compiler/src/utils.ts index 2686ddb48..ab86f0eea 100644 --- a/compiler/src/utils.ts +++ b/compiler/src/utils.ts @@ -1316,7 +1316,7 @@ export function removeDecorator(decorators: readonly ts.Decorator[], decoratorNa export function isFileInProject(filePath: string, projectRootPath: string): boolean { const relativeFilePath: string = toUnixPath(path.relative(toUnixPath(projectRootPath), toUnixPath(filePath))); // When processing ohmurl, hsp's filePath is consistent with moduleRequest - return fs.existsSync(filePath) && fs.statSync(filePath).isFile() && !relativeFilePath.startsWith('../'); + return path.isAbsolute(filePath) && fs.existsSync(filePath) && fs.statSync(filePath).isFile() && !relativeFilePath.startsWith('../'); } export function getProjectRootPath(filePath: string, projectConfig: Object, rootPathSet: Object): string { -- Gitee