Skip to content

Commit

Permalink
fix: preserve leading "./" in normalizePath result
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jun 1, 2020
1 parent a34702b commit d946dee
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/metro-resolver/src/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,16 @@ function isRelativeImport(filePath: string) {
}

function normalizePath(modulePath) {
const wasRelative = isRelativeImport(modulePath);
if (path.sep === '/') {
modulePath = path.normalize(modulePath);
} else if (path.posix) {
modulePath = path.posix.normalize(modulePath);
}

// Ensure `normalize` cannot strip leading "./"
if (wasRelative && modulePath[0] !== '.') {
modulePath = './' + modulePath;
}
return modulePath.replace(/\/$/, '');
}

Expand Down

0 comments on commit d946dee

Please sign in to comment.