Skip to content

Commit

Permalink
Return early with current authority if no domains
Browse files Browse the repository at this point in the history
  • Loading branch information
ljfio committed May 16, 2024
1 parent 73747fc commit e4448f1
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public InvisibleNodeUrlProvider(
/// <inheritdoc />
public UrlInfo? GetUrl(IPublishedContent content, UrlMode mode, string? culture, Uri current)
{
var currentAuthority = new Uri(current.GetLeftPart(UriPartial.Authority));

string route = GenerateRoute(content, culture);

if (mode == UrlMode.Auto || mode == UrlMode.Default || mode == UrlMode.Relative)
Expand All @@ -45,9 +47,14 @@ public InvisibleNodeUrlProvider(
var domainCache = umbracoContext.Domains;

var domainAndUris = domainCache.GetAll(false)
.Select(domain => new DomainAndUri(domain, current))
.Select(domain => new DomainAndUri(domain, currentAuthority))
.ToList();

if (!domainAndUris.Any())
return Uri.TryCreate(currentAuthority, route, out var currentCombined)
? UrlInfo.Url(currentCombined.ToString(), culture)
: null;

var mappedDomain = _siteDomainMapper.MapDomain(domainAndUris, current, culture, domainCache.DefaultCulture);

if (mappedDomain is null)
Expand Down

0 comments on commit e4448f1

Please sign in to comment.