╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ──╮ │src/web.zig│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2000 } │ │2001 │ │2002 fn findEmbed(request_path: []const u8) ?Embed { │ │1995 - const path = if (std.mem.eql(u8, request_path, "/")) │ │1996 - "index.html" │ │1997 - else if (request_path.len > 1 and request_path[0] == '/') │ │1998 - request_path[1..] │ │1999 - else │ │2000 - return null; │ │2003 + // embeds are matched before pages, so a dot keeps them from claiming a username or tab │ │2004 + comptime for (embeds) |embed| { │ │2005 + if (std.mem.indexOfScalar(u8, embed.path, '.') == null) @compileError("embed path needs a '.' so it can't shadow a page: " ++ embed.path);│ │2006 + }; │ │2007 + if (request_path.len < 2 or request_path[0] != '/') return null; │ │2008 + const path = request_path[1..]; │ │2009 │ │2010 for (embeds) |embed| { │ │2011 if (std.mem.eql(u8, path, embed.path)) return embed; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯