diff --git a/src/main/kotlin/no/nav/security/mock/oauth2/http/OAuth2HttpRequest.kt b/src/main/kotlin/no/nav/security/mock/oauth2/http/OAuth2HttpRequest.kt index 2dae03da..fefe5552 100644 --- a/src/main/kotlin/no/nav/security/mock/oauth2/http/OAuth2HttpRequest.kt +++ b/src/main/kotlin/no/nav/security/mock/oauth2/http/OAuth2HttpRequest.kt @@ -139,7 +139,17 @@ data class OAuth2HttpRequest( .encodedPath(originalUrl.encodedPath) .query(originalUrl.query).build() } else { - originalUrl + hostheader?.let { + val hostUri = URI(originalUrl.scheme, hostheader, null, null, null).parseServerAuthority() + HttpUrl.Builder() + .scheme(hostUri.scheme) + .host(hostUri.host) + .port(hostUri.port) + .encodedPath(originalUrl.encodedPath) + .query(originalUrl.query) + .build() + } ?: originalUrl + } }