Use relative path instead

This commit is contained in:
Hisham Bin Ateya
2020-04-05 01:14:12 +03:00
parent d406118d18
commit a2f756729c
3 changed files with 34 additions and 22 deletions

View File

@ -18,6 +18,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.2.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
<PackageReference Include="System.Text.Json" Version="4.7.1" />
</ItemGroup>

View File

@ -2,6 +2,8 @@
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
namespace Oqtane.Shared
{
@ -17,14 +19,29 @@ namespace Oqtane.Shared
public static string NavigateUrl(string alias, string path, string parameters)
{
var uriBuilder = alias == string.Empty
? new UriBuilder()
: new UriBuilder(alias);
if (!alias.StartsWith("/"))
{
alias = $"/{alias}";
}
uriBuilder.Path = path;
uriBuilder.Query = parameters;
if (!path.StartsWith("/"))
{
path = $"/{path}";
}
return uriBuilder.Uri.AbsoluteUri;
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)