fix(windows): fix directory cache regression "expected to end with a trailing slash" (#9144)

* okaaaaaaaay

* Revert "resolver: fix debug mode crash in test/bundler/bun-build-api.test.ts (#9140)"

This reverts commit 331d079dad.

* correctly fix the cache bust bug

this was introduced a couple of commits ago in my random fixes,
where i put the wrong fix to another directory caching bug.

i still stand by the assertion in place despite it causing many people
issues. it's precense will prevent subtle module resolutions failures.

* add an extra comment

* fix building a release build locally

* add a better test case for 3216

* staging

* fix mac issues

* ok

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
dave caruso
2024-02-28 14:51:14 -08:00
committed by GitHub
parent dc6af25b54
commit 360bbb4dea
13 changed files with 133 additions and 83 deletions

View File

@@ -742,6 +742,20 @@ pub fn withoutTrailingSlashWindowsPath(this: string) []const u8 {
return href;
}
/// This will remove ONE trailing slash at the end of a string,
/// but on Windows it will not remove the \ in "C:\"
pub fn pathWithoutTrailingSlashOne(str: []const u8) []const u8 {
return if (str.len > 0 and charIsAnySlash(str[str.len - 1]))
if (Environment.isWindows and str.len == 3 and str[1] == ':')
// Preserve "C:\"
str
else
// Remove one slash
str[0 .. str.len - 1]
else
str;
}
pub fn withoutLeadingSlash(this: string) []const u8 {
return std.mem.trimLeft(u8, this, "/");
}