mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
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:
@@ -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, "/");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user