Skip to content

Commit

Permalink
fix: make the result of parsing node direct imports system aware
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Dec 27, 2024
1 parent 8c480a5 commit d7cb92f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,8 @@ export class ResolverImplementation implements Resolver {
path: string;
}
| undefined {

// NOTE: We assume usage of path.posix.sep in the direct import
const directImportPattern =
/^(?<package>(?:@[a-z0-9-~._]+\/)?[a-z0-9-~][a-z0-9-~._]*)\/(?<path>.*)$/;

Expand All @@ -1332,7 +1334,11 @@ export class ResolverImplementation implements Resolver {
"Groups should be defined because they are part of the pattern",
);

return { package: match.groups.package, path: match.groups.path };
// NOTE: We replace path.posix.sep with path.sep here so that the returned
// path can be later safely treated as a system aware path
const parsedPath = match.groups.path.replaceAll(path.posix.sep, path.sep);

return { package: match.groups.package, path: parsedPath };
}
}

Expand Down

0 comments on commit d7cb92f

Please sign in to comment.