aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-22 21:25:26 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-22 21:25:26 -0800
commit4f41c3fb40a7cd23a48c1a888353059a69693fa8 (patch)
tree03d543e4471514c4e87ffbc371d5c60015339793 /src/bun.js
parentb249ed7257777f2d9b5fe18ba09694d75f0d0a90 (diff)
downloadbun-4f41c3fb40a7cd23a48c1a888353059a69693fa8.tar.gz
bun-4f41c3fb40a7cd23a48c1a888353059a69693fa8.tar.zst
bun-4f41c3fb40a7cd23a48c1a888353059a69693fa8.zip
[FileSystemRouter] Fix failing tests
Diffstat (limited to 'src/bun.js')
-rw-r--r--src/bun.js/api/filesystem_router.zig5
-rw-r--r--src/bun.js/bindings/bindings.zig4
2 files changed, 6 insertions, 3 deletions
diff --git a/src/bun.js/api/filesystem_router.zig b/src/bun.js/api/filesystem_router.zig
index 96c094b5c..f43a30d4e 100644
--- a/src/bun.js/api/filesystem_router.zig
+++ b/src/bun.js/api/filesystem_router.zig
@@ -290,6 +290,7 @@ pub const FileSystemRouter = struct {
.arena = arena,
.allocator = allocator,
};
+ router.config.dir = fs_router.base_dir.?.slice();
fs_router.base_dir.?.ref();
return fs_router;
}
@@ -701,8 +702,10 @@ pub const MatchedRoute = struct {
this: *MatchedRoute,
globalThis: *JSC.JSGlobalObject,
) callconv(.C) JSC.JSValue {
- if (this.route.query_string.len == 0) {
+ if (this.route.query_string.len == 0 and this.route.params.len == 0) {
return JSValue.createEmptyObject(globalThis, 0);
+ } else if (this.route.query_string.len == 0) {
+ return this.getParams(globalThis);
}
if (this.query_string_map == null) {
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index c88e0ba8f..b769625ec 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -236,8 +236,8 @@ pub const ZigString = extern struct {
}
pub fn cloneWithTrailingSlash(this: Slice, allocator: std.mem.Allocator) !Slice {
- var duped = try std.fmt.allocPrintZ(allocator, "{s}/", .{strings.withoutTrailingSlash(this.slice())});
- return Slice{ .allocator = NullableAllocator.init(allocator), .ptr = duped.ptr, .len = @truncate(u32, duped.len) };
+ var buf = try strings.cloneNormalizingSeparators(allocator, this.slice());
+ return Slice{ .allocator = NullableAllocator.init(allocator), .ptr = buf.ptr, .len = @truncate(u32, buf.len) };
}
pub fn cloneZ(this: Slice, allocator: std.mem.Allocator) !Slice {