remove changes to allow path to support urls - urls should be specified as redirects

This commit is contained in:
sbwalker 2024-03-29 10:15:24 -04:00
parent 93057d9449
commit 26220b2f54
2 changed files with 45 additions and 81 deletions

View File

@ -385,45 +385,34 @@
page.ParentId = Int32.Parse(_parentid);
}
// path can be a link to an external url
if (!_path.Contains("://"))
if (string.IsNullOrEmpty(_path))
{
if (string.IsNullOrEmpty(_path))
{
_path = _name;
}
_path = _name;
}
(_path, string parameters) = Utilities.ParsePath(_path);
if (_path.Contains("/"))
if (_path.Contains("/"))
{
if (_path.EndsWith("/") && _path != "/")
{
if (_path.EndsWith("/") && _path != "/")
{
_path = _path.Substring(0, _path.Length - 1);
}
_path = _path.Substring(_path.LastIndexOf("/") + 1);
_path = _path.Substring(0, _path.Length - 1);
}
if (_parentid == "-1")
{
page.Path = Utilities.GetFriendlyUrl(_path);
}
else
{
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId);
if (parent.Path == string.Empty)
{
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
}
else
{
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
}
}
page.Path += parameters;
_path = _path.Substring(_path.LastIndexOf("/") + 1);
}
if (_parentid == "-1")
{
page.Path = Utilities.GetFriendlyUrl(_path);
}
else
{
page.Path = _path;
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId);
if (parent.Path == string.Empty)
{
page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
}
else
{
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
}
}
var _pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
@ -497,14 +486,7 @@
}
else
{
if (!page.Path.Contains("://"))
{
NavigationManager.NavigateTo(page.Path); // redirect to new page created
}
else
{
NavigationManager.NavigateTo(NavigateUrl("admin/pages"));
}
NavigationManager.NavigateTo(page.Path); // redirect to new page created
}
}
else

View File

@ -380,7 +380,7 @@
}
else
{
if (_path.Contains("/") & !_path.Contains("://"))
if (_path.Contains("/"))
{
_path = _path.Substring(_path.LastIndexOf("/") + 1);
}
@ -529,45 +529,34 @@
_page.ParentId = Int32.Parse(_parentid);
}
// path can be a link to an external url
if (!_path.Contains("://"))
if (string.IsNullOrEmpty(_path))
{
if (string.IsNullOrEmpty(_path))
{
_path = _name;
}
_path = _name;
}
(_path, string parameters) = Utilities.ParsePath(_path);
if (_path.Contains("/"))
if (_path.Contains("/"))
{
if (_path.EndsWith("/") && _path != "/")
{
if (_path.EndsWith("/") && _path != "/")
{
_path = _path.Substring(0, _path.Length - 1);
}
_path = _path.Substring(_path.LastIndexOf("/") + 1);
_path = _path.Substring(0, _path.Length - 1);
}
if (_parentid == "-1")
{
_page.Path = Utilities.GetFriendlyUrl(_path);
}
else
{
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == _page.ParentId);
if (parent.Path == string.Empty)
{
_page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
}
else
{
_page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
}
}
_page.Path += parameters;
_path = _path.Substring(_path.LastIndexOf("/") + 1);
}
if (_parentid == "-1")
{
_page.Path = Utilities.GetFriendlyUrl(_path);
}
else
{
_page.Path = _path;
Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == _page.ParentId);
if (parent.Path == string.Empty)
{
_page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path);
}
else
{
_page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(_path);
}
}
var _pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
@ -658,14 +647,7 @@
}
else
{
if (!_page.Path.Contains("://"))
{
NavigationManager.NavigateTo(NavigateUrl(), true); // redirect to page being edited
}
else
{
NavigationManager.NavigateTo(NavigateUrl("admin/pages"));
}
NavigationManager.NavigateTo(NavigateUrl(), true); // redirect to page being edited
}
}
else