Skip to content

Commit

Permalink
Refactor addPlutoKtorInterceptor to improve URL handling (#332)
Browse files Browse the repository at this point in the history
- 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 <yfarag@jahez.net>
  • Loading branch information
YouSsef3Ssam and Youssef Essam authored Jan 25, 2025
1 parent e7aad71 commit 30afdd6
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ fun HttpClient.addPlutoKtorInterceptor() {
val request = requestUnBuilt.build()
val networkInterceptor = NetworkInterceptor.intercept(request.convert(), NetworkInterceptor.Option(NAME))
val callResult = try {
requestUnBuilt.url(networkInterceptor.actualOrMockRequestUrl)
val actualOrMockRequestUrl = networkInterceptor.actualOrMockRequestUrl
if (requestUnBuilt.url.buildString() != actualOrMockRequestUrl) {
requestUnBuilt.url(actualOrMockRequestUrl)
}
execute(requestUnBuilt)
} catch (e: IOException) {
networkInterceptor.onError(e)
Expand Down

0 comments on commit 30afdd6

Please # to comment.