fix fullurl 不抛出异常了

This commit is contained in:
2024-07-10 06:29:36 +08:00
parent 786051ddbf
commit 506704fd90
+2 -1
View File
@@ -114,8 +114,9 @@ public class SimApiStorage
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public string FullUrl(string path) public string FullUrl(string path)
{ {
if (string.IsNullOrEmpty(path)) return path;
if(path.StartsWith("http://") || path.StartsWith("https://")) return path; if(path.StartsWith("http://") || path.StartsWith("https://")) return path;
if (!(path.StartsWith('/') || path.StartsWith("~/"))) throw new Exception("path must start with / or ~/"); if (!(path.StartsWith('/') || path.StartsWith("~/"))) return path;
var httpRequest = HttpContextAccessor.HttpContext?.Request; var httpRequest = HttpContextAccessor.HttpContext?.Request;
var url = $"{httpRequest?.Scheme}://{httpRequest?.Host}"; var url = $"{httpRequest?.Scheme}://{httpRequest?.Host}";
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))