Skip to content

Commit

Permalink
Don't use path.dirname with file URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Jun 28, 2024
1 parent 05b5876 commit 4c8f956
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -916,11 +916,13 @@ export default async function analyze(
// Resolve the srcURL from the parentURL
const srcURL = new URL(pathOrSpecifier, parentURL).href;

// Resolve the srcPath relative to the current file
const srcPath = path.relative(
path.dirname(importMetaUrl),
srcURL,
const currentDirURL = importMetaUrl.slice(
0,
importMetaUrl.lastIndexOf('/'),
);

// Resolve the srcPath relative to the current file
const srcPath = path.relative(currentDirURL, srcURL);
// Make it a proper relative path
const relativeSrcPath = srcPath.startsWith('.')
? srcPath
Expand Down

0 comments on commit 4c8f956

Please sign in to comment.