Fix breaking change from alpha.17 release (#8899)

The semantics of the old path property included the query string,
and should be mapped from the new `target` which is the equivalent
field in the new recorded request. Using url.encodedPath only
provides the path component and omits the query component, resulting
in a breaking change.
This commit is contained in:
Kartikaya Gupta (kats)
2025-07-03 09:16:34 -04:00
committed by GitHub
parent 75661d41cd
commit dcb640c3da
2 changed files with 2 additions and 1 deletions

View File

@@ -112,7 +112,7 @@ internal fun mockwebserver3.RecordedRequest.unwrap(): RecordedRequest =
sequenceNumber = exchangeIndex,
failure = failure,
method = method,
path = url.encodedPath,
path = target,
handshake = handshake,
requestUrl = url,
)

View File

@@ -513,6 +513,7 @@ class MockWebServerTest {
assertThat(request.requestLine).isEqualTo(
"GET /a/deep/path?key=foo%20bar HTTP/1.1",
)
assertThat(request.path).isEqualTo("/a/deep/path?key=foo%20bar")
val requestUrl = request.requestUrl
assertThat(requestUrl!!.scheme).isEqualTo("http")
assertThat(requestUrl.host).isEqualTo(server.hostName)