-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(#732) Option to encode query params #1374
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
Conversation
|
Hello. This PR would be very useful. @helloanoop, do you plan to merge this feature? |
|
I'd be glad to fix the conflicts or change anything for this to be merged 👍 |
|
Hello @helloanoop or @lohxt1 , |
|
Hey CarlosLecval, are you planning on merging this in soon? It is a much welcome PR, so please ask if you need any help getting things resolved for this PR. |
|
Hello, |
|
hi @helloanoop, |
|
it's a bit sad to see this stalling here, this feature will be very useful |
|
Adding on to this. It's tremendously frustrating for it to make assumptions about encoding or not-encoding strings that don't seem to be an issue with Insomnia. In my case, I'm making requests to an API in which most endpoints expect a EDIT: Here's a quick and dirty pre-script as a workaround in the meantime. You can set it on a collection or folder. let url = req.getUrl();
if (url.includes("?")) {
let urlParts = url.split("?");
let urlParams = urlParts.slice(1,).join("?").split("&");
urlParams = urlParams.map(param => {
if (param.includes("=")) {
let paramParts = param.split("=");
let paramValue = paramParts.slice(1,).join("=");
paramValue = encodeURIComponent(paramValue);
return paramParts[0] + "=" + paramValue;
} else {
return param;
}
})
let newUrl = urlParts[0] + "?" + urlParams.join("&");
console.log(newUrl);
req.setUrl(newUrl);
} |
|
After reviewing the related issues, I believe the root cause of many of them is an inconsistency in how Bruno handles URL encoding between the below two components
Currently, Bruno automatically decodes the URL from the input field using URLSearchParams. However, when changes are made in the query parameters table, those changes are not encoded before updating the URL in the input field. This inconsistency leads to confusion and creates a number of edge cases. Another challenge is that we cannot determine whether the URL entered in the input field is already encoded. Given this uncertainty, it is not ideal for Bruno to assume the URL is encoded and then proceed with decoding while populating the query parameters table. Solution
Tradeoff: |
|
thanks for your answer @helloanoop .
So it's request sending time which is important. The encoding may have to be used for a request and not for another. |
|
This sounds like an excellent move on the project! I'm not sure what Insomnia does by comparison (as it is not open-source after all) but I imagine it is very much something like this. |
|
I think this MR could be closed since the release 2.8.0 proposed a settings by request allowing to automatically encode/decode query parameters (cf. #5089 ) |
|
Hey @CarlosLecval, Thanks so much for taking the time to contribute and open this PR! 🙌 The issue this PR aimed to address has since been handled in a different way through #5089, so we’ll be closing this one to avoid duplication. That said, we really appreciate your effort and initiative—please don’t hesitate to contribute again in the future! Thanks again! |
Description
solves: #732
Basically just added a checkbox to toggle the option to encode the query parameters as discussed in the issue
296139371-0a38a6e9-1a46-4487-90fb-60912fb28a35.mov