aboutsummaryrefslogtreecommitdiff
path: root/lib/compiler/std-docs.zig
diff options
context:
space:
mode:
authorJiacai Liu <dev@liujiacai.net>2024-05-22 04:21:17 +0800
committerGitHub <noreply@github.com>2024-05-21 23:21:17 +0300
commit6635360dbdbd6793b741648d51d25f12550e01db (patch)
tree457b034b5be4976221dbe865c1f61ccd26f0a80b /lib/compiler/std-docs.zig
parenteb0f871cb90cf7e3a1cfa7a160d3f224b42fd799 (diff)
downloadzig-6635360dbdbd6793b741648d51d25f12550e01db.tar.gz
zig-6635360dbdbd6793b741648d51d25f12550e01db.zip
std-docs: use `open` for macOS.
Diffstat (limited to 'lib/compiler/std-docs.zig')
-rw-r--r--lib/compiler/std-docs.zig18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/compiler/std-docs.zig b/lib/compiler/std-docs.zig
index e6240a3c70..ec324e065d 100644
--- a/lib/compiler/std-docs.zig
+++ b/lib/compiler/std-docs.zig
@@ -116,20 +116,19 @@ const Context = struct {
};
fn serveRequest(request: *std.http.Server.Request, context: *Context) !void {
- if (std.mem.eql(u8, request.head.target, "/") or
- std.mem.eql(u8, request.head.target, "/debug/"))
- {
+ const target = std.mem.trimRight(u8, request.head.target, "/");
+ if (target.len == 0 or std.mem.eql(u8, target, "/debug")) {
try serveDocsFile(request, context, "docs/index.html", "text/html");
- } else if (std.mem.eql(u8, request.head.target, "/main.js") or
- std.mem.eql(u8, request.head.target, "/debug/main.js"))
+ } else if (std.mem.eql(u8, target, "/main.js") or
+ std.mem.eql(u8, target, "/debug/main.js"))
{
try serveDocsFile(request, context, "docs/main.js", "application/javascript");
- } else if (std.mem.eql(u8, request.head.target, "/main.wasm")) {
+ } else if (std.mem.eql(u8, target, "/main.wasm")) {
try serveWasm(request, context, .ReleaseFast);
- } else if (std.mem.eql(u8, request.head.target, "/debug/main.wasm")) {
+ } else if (std.mem.eql(u8, target, "/debug/main.wasm")) {
try serveWasm(request, context, .Debug);
- } else if (std.mem.eql(u8, request.head.target, "/sources.tar") or
- std.mem.eql(u8, request.head.target, "/debug/sources.tar"))
+ } else if (std.mem.eql(u8, target, "/sources.tar") or
+ std.mem.eql(u8, target, "/debug/sources.tar"))
{
try serveSourcesTar(request, context);
} else {
@@ -433,6 +432,7 @@ fn openBrowserTab(gpa: Allocator, url: []const u8) !void {
fn openBrowserTabThread(gpa: Allocator, url: []const u8) !void {
const main_exe = switch (builtin.os.tag) {
.windows => "explorer",
+ .macos => "open",
else => "xdg-open",
};
var child = std.ChildProcess.init(&.{ main_exe, url }, gpa);