Fix bug when fetching page other than / or /api/*
This commit is contained in:
parent
7826ab4ad6
commit
d796825245
25
Program.cs
25
Program.cs
|
@ -1729,8 +1729,29 @@ namespace TYTD
|
||||||
}
|
}
|
||||||
public static void RootPath(HttpListenerRequest rq, HttpListenerResponse rp, Dictionary<string, string> args)
|
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[] p0 = System.Web.HttpUtility.UrlDecode(args["Path"]).Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
string path = $"WebSite/{p}";
|
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))
|
if (Directory.Exists(path))
|
||||||
{
|
{
|
||||||
string indexHtml = Path.Combine(path, "index.html");
|
string indexHtml = Path.Combine(path, "index.html");
|
||||||
|
|
Loading…
Reference in New Issue