Skip to content

Commit 2f4c49d

Browse files
authoredSep 28, 2022
Merge pull request #338 from tanettrimas/master
Make sure the urls are resolved with the correct host
2 parents c753cde + 380a139 commit 2f4c49d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎src/main/kotlin/no/nav/security/mock/oauth2/http/OAuth2HttpRequest.kt

+11-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,17 @@ data class OAuth2HttpRequest(
139139
.encodedPath(originalUrl.encodedPath)
140140
.query(originalUrl.query).build()
141141
} else {
142-
originalUrl
142+
hostheader?.let {
143+
val hostUri = URI(originalUrl.scheme, hostheader, null, null, null).parseServerAuthority()
144+
HttpUrl.Builder()
145+
.scheme(hostUri.scheme)
146+
.host(hostUri.host)
147+
.port(hostUri.port)
148+
.encodedPath(originalUrl.encodedPath)
149+
.query(originalUrl.query)
150+
.build()
151+
} ?: originalUrl
152+
143153
}
144154
}
145155

0 commit comments

Comments
 (0)
Please sign in to comment.