* Fixes #8276

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Jarred Sumner
2024-01-21 20:25:00 -08:00
committed by GitHub
parent b7b0e28b10
commit 6019665d4b
3 changed files with 11 additions and 24 deletions

View File

@@ -1516,7 +1516,7 @@ WebCore::FetchHeaders* WebCore__FetchHeaders__createFromUWS(JSC__JSGlobalObject*
size_t name_len = nameView.length();
LChar* data = nullptr;
auto value = String::createUninitialized(header.second.length(), data);
auto value = String::createUninitialized(header.second.length(), data);
memcpy(data, header.second.data(), header.second.length());
HTTPHeaderName name;
@@ -1718,7 +1718,7 @@ JSC__JSValue
JSC__JSObject__create(JSC__JSGlobalObject* globalObject, size_t initialCapacity, void* arg2,
void (*ArgFn3)(void* arg0, JSC__JSObject* arg1, JSC__JSGlobalObject* arg2))
{
JSC::JSObject* object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), initialCapacity);
JSC::JSObject* object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), std::min(static_cast<unsigned>(initialCapacity), JSFinalObject::maxInlineCapacity));
ArgFn3(arg2, object, globalObject);
@@ -2446,7 +2446,7 @@ JSC__JSValue JSC__JSValue__fromEntries(JSC__JSGlobalObject* globalObject, ZigStr
JSC::JSObject* object = nullptr;
{
JSC::ObjectInitializationScope initializationScope(vm);
object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), initialCapacity);
object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), std::min(static_cast<unsigned int>(initialCapacity), JSFinalObject::maxInlineCapacity));
if (!clone) {
for (size_t i = 0; i < initialCapacity; ++i) {

View File

@@ -17,32 +17,11 @@ pub const PathString = packed struct {
len: PathInt = 0,
const JSC = @import("root").bun.JSC;
pub fn fromJS(value: JSC.JSValue, global: *JSC.JSGlobalObject, exception: JSC.C.ExceptionRef) PathString {
if (!value.jsType().isStringLike()) {
JSC.JSError(JSC.getAllocator(global), "Only path strings are supported for now", .{}, global, exception);
return PathString{};
}
var zig_str = JSC.ZigString.init("");
value.toZigString(&zig_str, global);
return PathString.init(zig_str.slice());
}
pub inline fn asRef(this: PathString) JSC.JSValueRef {
return this.toValue().asObjectRef();
}
pub fn estimatedSize(this: *const PathString) usize {
return @as(usize, this.len);
}
pub fn toJS(this: PathString, ctx: JSC.C.JSContextRef, _: JSC.C.ExceptionRef) JSC.C.JSValueRef {
var zig_str = JSC.ZigString.init(this.slice());
zig_str.detectEncoding();
return zig_str.toValueAuto(ctx.ptr()).asObjectRef();
}
pub inline fn slice(this: anytype) string {
@setRuntimeSafety(false); // "cast causes pointer to be null" is fine here. if it is null, the len will be 0.
return @as([*]u8, @ptrFromInt(@as(usize, @intCast(this.ptr))))[0..this.len];

View File

@@ -47,6 +47,10 @@ it("should find files", () => {
`b.tsx`,
`foo/[id].tsx`,
`catch-all/[[...id]].tsx`,
// https://github.com/oven-sh/bun/issues/8276
// https://github.com/oven-sh/bun/issues/8278
...Array.from({ length: 65 }, (_, i) => `files/a${i}.tsx`),
]);
const router = new FileSystemRouter({
@@ -71,6 +75,10 @@ it("should find files", () => {
"/b": `${dir}/b.tsx`,
"/foo/[id]": `${dir}/foo/[id].tsx`,
"/catch-all/[[...id]]": `${dir}/catch-all/[[...id]].tsx`,
// https://github.com/oven-sh/bun/issues/8276
// https://github.com/oven-sh/bun/issues/8278
...Object.fromEntries(Array.from({ length: 65 }, (_, i) => [`/files/a${i}`, `${dir}/files/a${i}.tsx`])),
};
for (const route in fixture) {