mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
trim correctly (#8388)
Co-authored-by: dave caruso <me@paperdave.net> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
@@ -1135,6 +1135,7 @@ pub const ExportsMap = struct {
|
||||
map_data_ranges[i] = key_range;
|
||||
map_data_entries[i] = this.visit(prop.value.?);
|
||||
|
||||
// safe to use "/" on windows. exports in package.json does not use "\\"
|
||||
if (strings.endsWithComptime(key, "/") or strings.containsChar(key, '*')) {
|
||||
expansion_keys[expansion_key_i] = Entry.Data.Map.MapEntry{
|
||||
.value = map_data_entries[i],
|
||||
|
||||
@@ -2251,13 +2251,13 @@ pub const Resolver = struct {
|
||||
fn handleESMResolution(r: *ThisResolver, esm_resolution_: ESModule.Resolution, abs_package_path: string, kind: ast.ImportKind, package_json: *PackageJSON, package_subpath: string) ?MatchResult {
|
||||
var esm_resolution = esm_resolution_;
|
||||
if (!((esm_resolution.status == .Inexact or esm_resolution.status == .Exact or esm_resolution.status == .ExactEndsWithStar) and
|
||||
esm_resolution.path.len > 0 and esm_resolution.path[0] == '/'))
|
||||
esm_resolution.path.len > 0 and esm_resolution.path[0] == std.fs.path.sep))
|
||||
return null;
|
||||
|
||||
const abs_esm_path: string = brk: {
|
||||
var parts = [_]string{
|
||||
abs_package_path,
|
||||
strings.withoutLeadingSlash(esm_resolution.path),
|
||||
strings.withoutLeadingPathSeparator(esm_resolution.path),
|
||||
};
|
||||
break :brk r.fs.absBuf(&parts, bufs(.esm_absolute_package_path_joined));
|
||||
};
|
||||
|
||||
@@ -698,6 +698,10 @@ pub fn withoutLeadingSlash(this: string) []const u8 {
|
||||
return std.mem.trimLeft(u8, this, "/");
|
||||
}
|
||||
|
||||
pub fn withoutLeadingPathSeparator(this: string) []const u8 {
|
||||
return std.mem.trimLeft(u8, this, &.{std.fs.path.sep});
|
||||
}
|
||||
|
||||
pub fn endsWithAny(self: string, str: string) bool {
|
||||
const end = self[self.len - 1];
|
||||
for (str) |char| {
|
||||
|
||||
Reference in New Issue
Block a user