Skip to content

Commit 8aba70b

Browse files
Fixed absolute path issue on Linux
1 parent 11078c2 commit 8aba70b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/AngleSharp.Js/JsModuleLoader.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ public override ResolvedSpecifier Resolve(string referencingModuleLocation, Modu
6464
moduleUrl,
6565
SpecifierType.RelativeOrAbsolute);
6666
}
67+
68+
// Before passing to the base default module loader, make sure any relative paths are prepended with a dot
69+
// as Jint will otherwise resolve them as absolute file paths when running on Linux
70+
if (moduleRequest.Specifier.StartsWith("/"))
71+
{
72+
moduleRequest = new ModuleRequest($".{moduleRequest.Specifier}", moduleRequest.Attributes);
73+
}
74+
75+
if (referencingModuleLocation?.StartsWith("/") == true)
76+
{
77+
referencingModuleLocation = $".{referencingModuleLocation}";
78+
}
6779

6880
return base.Resolve(referencingModuleLocation, moduleRequest);
6981
}

0 commit comments

Comments
 (0)