Skip to content

Commit 30afdd6

Browse files
YouSsef3SsamYoussef Essam
andauthored
Refactor addPlutoKtorInterceptor to improve URL handling (#332)
- Replaced direct mutation of `requestUnBuilt.url` with a conditional check to ensure the URL is only updated if necessary. - Ensured proper handling of the actual or mock request URL in the interceptor logic. Co-authored-by: Youssef Essam <[email protected]>
1 parent e7aad71 commit 30afdd6

File tree

1 file changed

+4
-1
lines changed
  • pluto-plugins/plugins/network/interceptor-ktor/lib/src/main/kotlin/com/pluto/plugins/network/ktor

1 file changed

+4
-1
lines changed

pluto-plugins/plugins/network/interceptor-ktor/lib/src/main/kotlin/com/pluto/plugins/network/ktor/PlutoKtorHelper.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ fun HttpClient.addPlutoKtorInterceptor() {
2121
val request = requestUnBuilt.build()
2222
val networkInterceptor = NetworkInterceptor.intercept(request.convert(), NetworkInterceptor.Option(NAME))
2323
val callResult = try {
24-
requestUnBuilt.url(networkInterceptor.actualOrMockRequestUrl)
24+
val actualOrMockRequestUrl = networkInterceptor.actualOrMockRequestUrl
25+
if (requestUnBuilt.url.buildString() != actualOrMockRequestUrl) {
26+
requestUnBuilt.url(actualOrMockRequestUrl)
27+
}
2528
execute(requestUnBuilt)
2629
} catch (e: IOException) {
2730
networkInterceptor.onError(e)

0 commit comments

Comments
 (0)