diff options
author | 2022-02-24 20:32:57 -0800 | |
---|---|---|
committer | 2022-02-24 20:32:57 -0800 | |
commit | 208885e3d24d9ac5059b7360cba04c23821da2d9 (patch) | |
tree | 0d510a8313a1506a89e5180cfb9d3b4ba94859cc /src/http.zig | |
parent | 896195f5e377beb68fe743f0eb75d023e16703aa (diff) | |
download | bun-208885e3d24d9ac5059b7360cba04c23821da2d9.tar.gz bun-208885e3d24d9ac5059b7360cba04c23821da2d9.tar.zst bun-208885e3d24d9ac5059b7360cba04c23821da2d9.zip |
[bun dev] Fix bug with not transpiling files at the root
Diffstat (limited to '')
-rw-r--r-- | src/http.zig | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/src/http.zig b/src/http.zig index 1d08a334d..58176df6c 100644 --- a/src/http.zig +++ b/src/http.zig @@ -497,6 +497,10 @@ pub const RequestContext = struct { _path = tmp_buildfile_buf[0 .. relative_unrooted_path.len + "/index.html".len]; } + if (extensionless and !strings.eqlComptime(std.fs.path.extension(_path), ".html")) { + break; + } + if (public_dir.openFile(_path, .{})) |file| { const __path = _path; relative_unrooted_path = __path; @@ -3645,7 +3649,7 @@ pub const Server = struct { // Note: the public folder may actually just be the root folder // In this case, we only check if the pathname has no extension if (!finished) { - if (req_ctx.matchPublicFolder(comptime features.public_folder != .first)) |result| { + if (req_ctx.matchPublicFolder(comptime features.public_folder == .last or features.single_page_app_routing)) |result| { finished = true; req_ctx.renderServeResult(result) catch |err| { Output.printErrorln("FAIL [{s}] - {s}: {s}", .{ @errorName(err), req.method, req.path }); @@ -3854,18 +3858,36 @@ pub const Server = struct { }, ); } else if (server.bundler.options.routes.static_dir_enabled) { - if (!public_folder_is_top_level) { - try server.run( - ConnectionFeatures{ - .public_folder = .first, - }, - ); + if (server.bundler.options.routes.single_page_app_routing) { + if (!public_folder_is_top_level) { + try server.run( + ConnectionFeatures{ + .public_folder = .first, + .single_page_app_routing = true, + }, + ); + } else { + try server.run( + ConnectionFeatures{ + .public_folder = .last, + .single_page_app_routing = true, + }, + ); + } } else { - try server.run( - ConnectionFeatures{ - .public_folder = .last, - }, - ); + if (!public_folder_is_top_level) { + try server.run( + ConnectionFeatures{ + .public_folder = .first, + }, + ); + } else { + try server.run( + ConnectionFeatures{ + .public_folder = .last, + }, + ); + } } } else if (server.bundler.options.routes.single_page_app_routing) { try server.run( |