aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/api/filesystem_router.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/api/filesystem_router.zig')
-rw-r--r--src/bun.js/api/filesystem_router.zig9
1 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 216f66b7f..edb666040 100644
--- a/src/bun.js/api/filesystem_router.zig
+++ b/src/bun.js/api/filesystem_router.zig
@@ -75,6 +75,8 @@ const DeprecatedGlobalRouter = struct {
};
var path_: ?ZigString.Slice = null;
+ var req_url_slice: ZigString.Slice = .{};
+ defer req_url_slice.deinit();
var pathname: string = "";
defer {
if (path_) |path| {
@@ -88,7 +90,8 @@ const DeprecatedGlobalRouter = struct {
var url = URL.parse(path_.?.slice());
pathname = url.pathname;
} else if (arg.as(Request)) |req| {
- var url = URL.parse(req.url);
+ req_url_slice = req.url.toUTF8(bun.default_allocator);
+ var url = URL.parse(req_url_slice.slice());
pathname = url.pathname;
}
@@ -389,11 +392,11 @@ pub const FileSystemRouter = struct {
if (argument.isCell()) {
if (argument.as(JSC.WebCore.Request)) |req| {
req.ensureURL() catch unreachable;
- break :brk ZigString.Slice.fromUTF8NeverFree(req.url).clone(globalThis.allocator()) catch unreachable;
+ break :brk req.url.toUTF8(globalThis.allocator());
}
if (argument.as(JSC.WebCore.Response)) |resp| {
- break :brk ZigString.Slice.fromUTF8NeverFree(resp.url).clone(globalThis.allocator()) catch unreachable;
+ break :brk resp.url.toUTF8(globalThis.allocator());
}
}