From 52f4ba767acb3d063e53d073989f91a407a7df61 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 16 Dec 2021 01:48:31 -0800 Subject: [PATCH] [http] Fix bug with `Link` header --- src/http.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/http.zig b/src/http.zig index e347903778..4f978d44de 100644 --- a/src/http.zig +++ b/src/http.zig @@ -225,7 +225,11 @@ pub const RequestContext = struct { writer.writeAll(std.mem.trim(u8, this.bundler.options.routes.asset_prefix_path, "/")) catch break :module_preload; } - writer.writeAll(match.file_path[Fs.FileSystem.instance.top_level_dir.len..]) catch break :module_preload; + // include that trailing slash + // this should never overflow because the directory will be "/" if it's a root + if (comptime Environment.isDebug) std.debug.assert(Fs.FileSystem.instance.top_level_dir.len > 0); + + writer.writeAll(match.file_path[Fs.FileSystem.instance.top_level_dir.len - 1 ..]) catch break :module_preload; writer.writeAll(">; rel=modulepreload") catch break :module_preload;