Fix bug when fetching page other than / or /api/*
This commit is contained in:
parent
7826ab4ad6
commit
d796825245
23
Program.cs
23
Program.cs
|
@ -1729,7 +1729,28 @@ 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[] 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))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue