Sanitize _aliasname by removing protocols
This commit is contained in:
parent
7744099ee5
commit
3a5dc62908
@ -818,24 +818,21 @@
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_aliasname))
|
||||
{
|
||||
// Remove 'http://' and 'https://' from the alias name
|
||||
string cleanedAliasName = _aliasname.Replace("http://", "").Replace("https://", "");
|
||||
|
||||
_aliasname = _aliasname.Replace("http://", "").Replace("https://", "");
|
||||
var aliases = await AliasService.GetAliasesAsync();
|
||||
// Check if the cleaned alias name exists in the database
|
||||
var alias = aliases.Where(item => item.Name == cleanedAliasName).FirstOrDefault();
|
||||
var alias = aliases.Where(item => item.Name == _aliasname).FirstOrDefault();
|
||||
bool unique = (alias == null || alias.AliasId == _aliasid);
|
||||
if (unique)
|
||||
{
|
||||
if (_aliasid == 0)
|
||||
{
|
||||
alias = new Alias { SiteId = PageState.Site.SiteId, TenantId = PageState.Site.TenantId, Name = cleanedAliasName, IsDefault = bool.Parse(_defaultalias) };
|
||||
alias = new Alias { SiteId = PageState.Site.SiteId, TenantId = PageState.Site.TenantId, Name = _aliasname, IsDefault = bool.Parse(_defaultalias) };
|
||||
await AliasService.AddAliasAsync(alias);
|
||||
}
|
||||
else
|
||||
{
|
||||
alias = _aliases.Single(item => item.AliasId == _aliasid);
|
||||
alias.Name = cleanedAliasName;
|
||||
alias.Name = _aliasname;
|
||||
alias.IsDefault = bool.Parse(_defaultalias);
|
||||
await AliasService.UpdateAliasAsync(alias);
|
||||
}
|
||||
|
Reference in New Issue
Block a user