From 3296d81b1423cc57c6ecee8c49d4770cd314c08a 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: #ICXPRF 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 7b0a287a9..247f74696 100644 --- a/compiler/src/utils.ts +++ b/compiler/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 { -- Gitee