Skip to content

Commit

Permalink
Merge pull request #4622 from dennisreimann/domain-mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Kukks committed Feb 13, 2023
2 parents 72a9e67 + 3c34433 commit b5abcd5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions BTCPayServer/Filters/DomainMappingConstraintAttribute.cs
Expand Up @@ -38,8 +38,9 @@ public bool Accept(ActionConstraintContext context)
if (matchedDomainMapping != null)
{
var req = context.RouteContext.HttpContext.Request;
var url = new UriBuilder(req.Scheme, matchedDomainMapping.Domain).ToString();
context.RouteContext.HttpContext.Response.Redirect(url);
var uri = new UriBuilder(req.Scheme, matchedDomainMapping.Domain);
if (req.Host.Port.HasValue) uri.Port = req.Host.Port.Value;
context.RouteContext.HttpContext.Response.Redirect(uri.ToString());
return true;
}
}
Expand All @@ -55,15 +56,17 @@ public bool Accept(ActionConstraintContext context)
return false;
if (appType != matchedDomainMapping.AppType)
return false;
context.RouteContext.RouteData.Values.Add("appId", matchedDomainMapping.AppId);
return true;
if (!hasAppId)
{
context.RouteContext.RouteData.Values.Add("appId", matchedDomainMapping.AppId);
return true;
}
}
}

if (AppType == policies.RootAppType)
if (AppType == policies.RootAppType && !hasAppId && !string.IsNullOrEmpty(policies.RootAppId))
{
context.RouteContext.RouteData.Values.Add("appId", policies.RootAppId);

return true;
}

Expand Down

0 comments on commit b5abcd5

Please sign in to comment.