#5 Implement replay URLs

This commit is contained in:
Andrio Celos
2022-12-26 14:36:04 +11:00
parent 42956e9e9e
commit 0cdfc3bbbd
4 changed files with 28 additions and 14 deletions

View File

@@ -65,7 +65,9 @@ internal class Program {
private static void HttpServer_OnRequest(object? sender, HttpRequestEventArgs e) {
e.Response.AppendHeader("Access-Control-Allow-Origin", "*");
if (!e.Request.RawUrl.StartsWith("/api/")) {
var path = e.Request.RawUrl == "/" || e.Request.RawUrl.StartsWith("/game/") ? "index.html" : e.Request.RawUrl[1..];
var path = e.Request.RawUrl == "/" || e.Request.RawUrl.StartsWith("/game/") || e.Request.RawUrl.StartsWith("/replay/")
? "index.html"
: e.Request.RawUrl[1..];
if (e.TryReadFile(path, out var bytes))
SetResponse(e.Response, HttpStatusCode.OK,
Path.GetExtension(path) switch {