make sure dependency slashes are normalized

This commit is contained in:
Dylan Conway
2025-01-20 01:26:32 -08:00
parent 16b10f9d25
commit 0e0670af1b
2 changed files with 4 additions and 2 deletions

View File

@@ -4744,7 +4744,7 @@ pub const Package = extern struct {
const workspace = dependency_version.value.workspace.slice(buf);
const path = string_builder.append(String, if (strings.eqlComptime(workspace, "*")) "*" else brk: {
var buf2: bun.PathBuffer = undefined;
break :brk Path.relativePlatform(
const rel = Path.relativePlatform(
FileSystem.instance.top_level_dir,
Path.joinAbsStringBuf(
FileSystem.instance.top_level_dir,
@@ -4758,6 +4758,8 @@ pub const Package = extern struct {
.auto,
false,
);
bun.path.dangerouslyConvertPathToPosixInPlace(u8, Path.relative_to_common_path_buf[0..rel.len]);
break :brk rel;
});
if (comptime Environment.allow_assert) {
assert(path.len() > 0);

View File

@@ -307,7 +307,7 @@ pub fn longestCommonPathPosix(input: []const []const u8) []const u8 {
return longestCommonPathGeneric(input, .posix);
}
threadlocal var relative_to_common_path_buf: bun.PathBuffer = undefined;
pub threadlocal var relative_to_common_path_buf: bun.PathBuffer = undefined;
/// Find a relative path from a common path
// Loosely based on Node.js' implementation of path.relative