File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
packages/schema/src/utils Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { isFromStdlib } from '@zenstackhq/sdk';
19
19
import { AstNode , getDocument , LangiumDocuments , Mutable } from 'langium' ;
20
20
import { URI , Utils } from 'vscode-uri' ;
21
21
import { findNodeModulesFile } from './pkg-utils' ;
22
+ import { isAbsolute } from 'node:path'
22
23
23
24
export function extractDataModelsWithAllowRules ( model : Model ) : DataModel [ ] {
24
25
return model . declarations . filter (
@@ -96,18 +97,17 @@ export function getDataModelFieldReference(expr: Expression): DataModelField | u
96
97
97
98
export function resolveImportUri ( imp : ModelImport ) : URI | undefined {
98
99
if ( ! imp . path ) return undefined ; // This will return true if imp.path is undefined, null, or an empty string ("").
99
-
100
+
100
101
if ( ! imp . path . endsWith ( '.zmodel' ) ) {
101
102
imp . path += '.zmodel' ;
102
103
}
103
104
104
105
if (
105
106
! imp . path . startsWith ( '.' ) // Respect relative paths
106
- && ! imp . path . startsWith ( '/' ) // Respect absolute paths (Unix)
107
- && ! / ^ [ a - z A - Z ] : \\ / . test ( imp . path ) // Respect absolute paths (Windows)
107
+ && ! isAbsolute ( imp . path ) // Respect Absolute paths
108
108
) {
109
109
imp . path = findNodeModulesFile ( imp . path ) ?? imp . path ;
110
- }
110
+ }
111
111
112
112
const dirUri = Utils . dirname ( getDocument ( imp ) . uri ) ;
113
113
return Utils . resolvePath ( dirUri , imp . path ) ;
You can’t perform that action at this time.
0 commit comments