Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.security.interfaces.RSAPublicKey;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

Expand Down Expand Up @@ -128,14 +129,19 @@ public static HttpUrl buildBaseUrl(Uri url) {
throw new NullPointerException("Base uri cannot be null");
}

String host = httpUrl.host();
HttpUrl.Builder newUrlbuilder = httpUrl.newBuilder();

String host = httpUrl.host();
if (host.endsWith("auth0.com")) {
host = host.replace(".guardian", "");
newUrlbuilder.host(host.replace(".guardian", ""));
}

int applianceMfaPathIndex = httpUrl.pathSegments().indexOf("appliance-mfa");
if (applianceMfaPathIndex >= 0) {
newUrlbuilder.removePathSegment(applianceMfaPathIndex);
}

return httpUrl.newBuilder()
.host(host)
return newUrlbuilder
.addPathSegments(CONSENT_PATH)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ public void testBuildBaseUrl() {
"should handle custom domain url with guardian subdomain",
"https://guardian.custom-domain.com",
"https://guardian.custom-domain.com/rich-consents"
),
new TestCase(
"should handle canonical domain url with appliance-mfa path",
"https://samples.eu.auth0.com/appliance-mfa",
"https://samples.eu.auth0.com/rich-consents"
),
new TestCase(
"should handle custom domain url with appliance-mfa path",
"https://custom-domain.com/appliance-mfa",
"https://custom-domain.com/rich-consents"
)
);

Expand Down