feat: Blazor 路径转换方法支持 http https 协议

This commit is contained in:
Argo Zhang 2020-02-21 13:14:56 +08:00
parent 97ebce39ac
commit 2454ea3684
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
1 changed files with 3 additions and 2 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Components;
@ -40,6 +41,6 @@ namespace Bootstrap.Admin.Pages.Extensions
/// <param name="nav"></param>
/// <param name="url"></param>
/// <returns></returns>
public static string ToBlazorLink(this NavigationManager? nav, string url) => $"{nav?.BaseUri}{url.TrimStart('/')}";
public static string ToBlazorLink(this NavigationManager? nav, string url) => (url.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) ? url : $"{nav?.BaseUri}{url.TrimStart('/')}";
}
}