╭ changed ──╮ │src/web.zig│ ╰───────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2212 if (!sameLink(link, open_link)) { │ │2213 if (open_link != null) try output.appendSlice(allocator, "</a>"); │ │2214 if (link) |url| { │ │2215 - try output.appendSlice(allocator, "<a class=\"cell-link\" tabindex=\"-1\" target=\"_blank\" rel=\"noopener noreferrer\" href=\"");│ │2215 + // a page path opens in this tab, any other url in a new one │ │2216 + try output.appendSlice(allocator, if (url[0] == '/') │ │2217 + "<a class=\"cell-link\" tabindex=\"-1\" href=\"" │ │2218 + else │ │2219 + "<a class=\"cell-link\" tabindex=\"-1\" target=\"_blank\" rel=\"noopener noreferrer\" href=\""); │ │2220 try appendEscapedHtml(allocator, output, url); │ │2221 try output.appendSlice(allocator, "\">"); │ │2222 } │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────╮ │2512 return i + s.len; │ │2513 } │ │2514 │ │2511 -// a cell's link as an href, when it's a web or mail url │ │2515 +// a cell's link as an href, when it's a page path or a web or mail url│ │2516 fn webLink(link: ?[]const u8) ?[]const u8 { │ │2517 const url = link orelse return null; │ │2518 + // a page path, not a protocol-relative url │ │2519 + if (url.len > 1 and url[0] == '/' and url[1] != '/') return url; │ │2520 for ([_][]const u8{ "http://", "https://", "mailto:" }) |scheme| { │ │2521 if (std.ascii.startsWithIgnoreCase(url, scheme)) return url; │ │2522 } │ ╰─────────────────────────────────────────────────────────────────────────────╯