Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f78c3a0e0d |
@@ -127,6 +127,27 @@ public class SimApiStorage
|
|||||||
return path.StartsWith('~') ? string.Concat(url, path.AsSpan(1, path.Length - 1)) : $"{ServeUrl}{path}";
|
return path.StartsWith('~') ? string.Concat(url, path.AsSpan(1, path.Length - 1)) : $"{ServeUrl}{path}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取一个Path得访问URL
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string? GetUrl(string? path)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(path)) return path;
|
||||||
|
if (path.StartsWith("~/"))
|
||||||
|
{
|
||||||
|
var httpRequest = HttpContextAccessor.HttpContext?.Request;
|
||||||
|
var url = $"{httpRequest?.Scheme}://{httpRequest?.Host}";
|
||||||
|
return string.Concat(url, path.AsSpan(1, path.Length - 1));
|
||||||
|
}
|
||||||
|
if (path.StartsWith('/'))
|
||||||
|
{
|
||||||
|
return $"{ServeUrl}{path}";
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 从URL中获取相对路径 (如果url不是当前服务器的url,则原样返回)
|
/// 从URL中获取相对路径 (如果url不是当前服务器的url,则原样返回)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user