Skip to content

Commit

Permalink
Merge pull request #3983 from berkarslan-xo/bugfix/Issue-3982
Browse files Browse the repository at this point in the history
Issue-3982 - URLs added to pages unexpectedly redirect to the original URL
  • Loading branch information
mitchelsellers authored Aug 18, 2020
2 parents 1642e97 + 59f5810 commit 0bd8b22
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,30 @@ public PageUrlResult CreateCustomUrl(SaveUrlDto dto, TabInfo tab)
}

var seqNum = (tab.TabUrls.Count > 0) ? tab.TabUrls.Max(t => t.SeqNum) + 1 : 1;
var portalLocales = LocaleController.Instance.GetLocales(portalSettings.PortalId);
var cultureCode = portalLocales.Where(l => l.Value.KeyID == dto.LocaleKey)
.Select(l => l.Value.Code)
.SingleOrDefault() ?? portalSettings.CultureCode;
var portalLocales = LocaleController.Instance.GetLocales(portalSettings.PortalId);

// Get the culture code of selected portal alias
var alias = PortalAliasController.Instance
.GetPortalAliasesByPortalId(portalSettings.PortalId)
.SingleOrDefault(a => a.PortalAliasID == dto.SiteAliasKey);
Func<KeyValuePair<string, Locale>, bool> localeFilter = null;
if (alias != null &&
!string.IsNullOrWhiteSpace(alias.CultureCode))
{
localeFilter = l => l.Key == alias.CultureCode;
}
else
{
localeFilter = l => l.Value.KeyID == dto.LocaleKey;
}

var cultureCode = portalLocales.Where(localeFilter)
.Select(l => l.Value.Code)
.SingleOrDefault() ?? portalSettings.CultureCode;

var portalAliasUsage = (PortalAliasUsageType)dto.SiteAliasUsage;
if (portalAliasUsage == PortalAliasUsageType.Default)
{
var alias = PortalAliasController.Instance.GetPortalAliasesByPortalId(portalSettings.PortalId)
.SingleOrDefault(a => a.PortalAliasID == dto.SiteAliasKey);

if (string.IsNullOrEmpty(cultureCode) || alias == null)
{
return new PageUrlResult
Expand Down

0 comments on commit 0bd8b22

Please sign in to comment.