Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Query Parameters in URL with PlutoKtorInterceptor #331

Closed
YouSsef3Ssam opened this issue Jan 1, 2025 · 1 comment · Fixed by #332
Closed

Duplicate Query Parameters in URL with PlutoKtorInterceptor #331

YouSsef3Ssam opened this issue Jan 1, 2025 · 1 comment · Fixed by #332
Assignees
Labels
bug Something isn't working

Comments

@YouSsef3Ssam
Copy link
Contributor

Describe the bug
When using PlutoKtorInterceptor, the query parameters in the request URL are duplicated. This issue occurs when making HTTP requests with query parameters using Ktor. Without the interceptor, the query parameters appear correctly formatted.

To Reproduce

  1. Set up a HttpClient in a Ktor-based project.
  2. Install the PlutoKtorInterceptor plugin.
  3. Make a GET request with multiple query parameters using the parameter function.
  4. Observe the logged request URL.

Expected behavior
The query parameters in the URL should not be duplicated.

Actual Behavior
Query parameters are duplicated in the URL.

Code Snippe

1- With PlutoKtorInterceptor Enabled

private fun fireRequest() {
    val client = HttpClient(Android.create()) {
        if (BuildConfig.DEBUG) {
            install(Logging) {
                level = LogLevel.ALL
                logger = object : Logger {
                    override fun log(message: String) {
                        Timber.d("Network Logger-> $message")
                    }
                }
            }
        }
        install(PlutoKtorInterceptor)
    }

    lifecycleScope.launch(Dispatchers.IO) {
        client.get("https://www.google.com/") {
            parameter("q", "ktor")
            parameter("status", "new")
        }
    }
}

Result:
image

2- With PlutoKtorInterceptor Disabled:

private fun fireRequest() {
    val client = HttpClient(Android.create()) {
        if (BuildConfig.DEBUG) {
            install(Logging) {
                level = LogLevel.ALL
                logger = object : Logger {
                    override fun log(message: String) {
                        Timber.d("Network Logger-> $message")
                    }
                }
            }
        }
//        install(PlutoKtorInterceptor)
    }

    lifecycleScope.launch(Dispatchers.IO) {
        client.get("https://www.google.com/") {
            parameter("q", "ktor")
            parameter("status", "new")
        }
    }
}

Result:
image

@YouSsef3Ssam
Copy link
Contributor Author

@srtvprateek Any Updates On This?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants