Address feedback
This commit is contained in:
parent
a2f756729c
commit
e10015c11a
|
@ -18,7 +18,6 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.2.0" />
|
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
|
||||||
<PackageReference Include="System.Text.Json" Version="4.7.1" />
|
<PackageReference Include="System.Text.Json" Version="4.7.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Http.Extensions;
|
|
||||||
|
|
||||||
namespace Oqtane.Shared
|
namespace Oqtane.Shared
|
||||||
{
|
{
|
||||||
|
@ -19,29 +17,15 @@ namespace Oqtane.Shared
|
||||||
|
|
||||||
public static string NavigateUrl(string alias, string path, string parameters)
|
public static string NavigateUrl(string alias, string path, string parameters)
|
||||||
{
|
{
|
||||||
if (!alias.StartsWith("/"))
|
var uriBuilder = new UriBuilder
|
||||||
{
|
{
|
||||||
alias = $"/{alias}";
|
Path = !string.IsNullOrEmpty(alias)
|
||||||
}
|
? $"{alias}/{path}"
|
||||||
|
: $"{path}",
|
||||||
|
Query = parameters
|
||||||
|
};
|
||||||
|
|
||||||
if (!path.StartsWith("/"))
|
return uriBuilder.Uri.PathAndQuery;
|
||||||
{
|
|
||||||
path = $"/{path}";
|
|
||||||
}
|
|
||||||
|
|
||||||
var pathPaseValue = alias == string.Empty
|
|
||||||
? default
|
|
||||||
: new PathString(alias);
|
|
||||||
|
|
||||||
var pathValue = path == string.Empty
|
|
||||||
? default
|
|
||||||
: new PathString(path);
|
|
||||||
|
|
||||||
var queryStringValue = parameters == string.Empty
|
|
||||||
? default
|
|
||||||
: new QueryString($"?{parameters}");
|
|
||||||
|
|
||||||
return UriHelper.BuildRelative(pathPaseValue, pathValue, queryStringValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string EditUrl(string alias, string path, int moduleid, string action, string parameters)
|
public static string EditUrl(string alias, string path, int moduleid, string action, string parameters)
|
||||||
|
|
|
@ -8,13 +8,13 @@ namespace Oqtane.Test.Oqtane.Shared.Tests
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("contoso", "login", "returnUrl=/admin", "/contoso/login?returnUrl=/admin")]
|
[InlineData("contoso", "login", "returnUrl=/admin", "/contoso/login?returnUrl=/admin")]
|
||||||
[InlineData("contoso", "admin", "", "/contoso/admin")]
|
[InlineData("contoso", "admin", "", "/contoso/admin")]
|
||||||
[InlineData("contoso", "", "pageId=4", "/contoso/?pageId=4")]
|
[InlineData("contoso", "", "pageId=4", "/contoso?pageId=4")]
|
||||||
[InlineData("contoso", "", "pageId=4&moduleId=10", "/contoso/?pageId=4&moduleId=10")]
|
[InlineData("contoso", "", "pageId=4&moduleId=10", "/contoso?pageId=4&moduleId=10")]
|
||||||
[InlineData("contoso", "", "", "/contoso/")]
|
[InlineData("contoso", "", "", "/contoso/")]
|
||||||
[InlineData("", "login", "returnUrl=/admin", "/login?returnUrl=/admin")]
|
[InlineData("", "login", "returnUrl=/admin", "/login?returnUrl=/admin")]
|
||||||
[InlineData("", "admin", "", "/admin")]
|
[InlineData("", "admin", "", "/admin")]
|
||||||
[InlineData("", "", "pageId=4", "/?pageId=4")]
|
[InlineData("", "", "pageId=4", "?pageId=4")]
|
||||||
[InlineData("", "", "pageId=4&moduleId=10", "/?pageId=4&moduleId=10")]
|
[InlineData("", "", "pageId=4&moduleId=10", "?pageId=4&moduleId=10")]
|
||||||
[InlineData("", "", "", "/")]
|
[InlineData("", "", "", "/")]
|
||||||
public void NavigateUrlTest(string alias, string path, string parameters, string expectedUrl)
|
public void NavigateUrlTest(string alias, string path, string parameters, string expectedUrl)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user