Fix bug when fetching page other than / or /api/*

This commit is contained in:
Michael Nolan 2022-03-31 05:51:59 -05:00
parent 7826ab4ad6
commit d796825245
1 changed files with 23 additions and 2 deletions

View File

@ -1729,8 +1729,29 @@ namespace TYTD
}
public static void RootPath(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary<string, string> args)
{
string p = System.Web.HttpUtility.UrlDecode(args["Path"]).Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries)[0];
string path = $"WebSite/{p}";
string[] p0 = System.Web.HttpUtility.UrlDecode(args["Path"]).Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries);
string p = p0[0];
args.Clear();
if (p0.Length >= 2)
{
foreach (var item in p0[1].Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries))
{
var sub = item.Split(new char[] { '=' });
if (sub.Length == 2)
{
if (!args.ContainsKey(sub[0]))
args.Add(sub[0], sub[1]);
}
else
{
if (!args.ContainsKey(sub[0]))
args.Add(sub[0], "");
}
}
}
string path =$"WebSite/{p}";
if (Directory.Exists(path))
{
string indexHtml = Path.Combine(path, "index.html");