Files
juipnet/Infrastructure/WxApi/Util/UrlHelper.cs

48 lines
1.3 KiB
C#
Raw Normal View History

2024-04-10 13:55:27 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Hncore.Pass.MsgCenter.Util
{
public class UrlHelper
{
public static UrlMethodModel ParseUrl(string data)
{
var index = data.IndexOf('/');
if (index != -1)
{
data = data.Substring(index + 1);
}
UrlMethodModel model = new UrlMethodModel();
var token = data.Split('?');
if (token.Length > 0)
{
model.Method = token[0];
}
if (token.Length > 1)
{
var kvs = token[1].Split('&');
foreach (var item in kvs)
{
var kv = item.Split('=');
if (kv.Length > 1)
{
var key = kv[0].ToLower();
var value = kv[1];
model.Args[key] = value;
}
}
}
return model;
}
}
public class UrlMethodModel
{
public string Method { get; set; } = "";
public Dictionary<string, string> Args { get; set; } = new Dictionary<string, string>();
}
}