Skip to content

Commit

Permalink
Fixed absolute path issue on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanenckevort committed Mar 18, 2024
1 parent 11078c2 commit 8aba70b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/AngleSharp.Js/JsModuleLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ public override ResolvedSpecifier Resolve(string referencingModuleLocation, Modu
moduleUrl,
SpecifierType.RelativeOrAbsolute);
}

// Before passing to the base default module loader, make sure any relative paths are prepended with a dot
// as Jint will otherwise resolve them as absolute file paths when running on Linux
if (moduleRequest.Specifier.StartsWith("/"))
{
moduleRequest = new ModuleRequest($".{moduleRequest.Specifier}", moduleRequest.Attributes);
}

if (referencingModuleLocation?.StartsWith("/") == true)
{
referencingModuleLocation = $".{referencingModuleLocation}";
}

return base.Resolve(referencingModuleLocation, moduleRequest);
}
Expand Down

0 comments on commit 8aba70b

Please sign in to comment.