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

[FIX] cURL code snippet contains encoded value for special char + instead of char itself #735

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion codegens/curl/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ var self = module.exports = {
},

/**
* Encode param except the following characters- [,{,},],%
* Encode param except the following characters- [,{,},],%,+
*
* @param {String} param
* @returns {String}
Expand All @@ -225,6 +225,7 @@ var self = module.exports = {
.replace(/%7B/g, '{')
.replace(/%5D/g, ']')
.replace(/%7D/g, '}')
.replace(/%2B/g, '+')
.replace(/%25/g, '%')
.replace(/'/g, '%27');
},
Expand Down
4 changes: 2 additions & 2 deletions codegens/curl/test/unit/convert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,12 +676,12 @@ describe('curl convert function', function () {

it('should not encode unresolved query params and ' +
'encode every other query param, both present together', function () {
rawUrl = 'https://postman-echo.com/get?key1={{value}}&key2=\'a b c\'';
rawUrl = 'https://postman-echo.com/get?key1={{value}}&key2=\'a b+c\'';
urlObject = new sdk.Url(rawUrl);
outputUrlString = getUrlStringfromUrlObject(urlObject);
expect(outputUrlString).to.not.include('key1=%7B%7Bvalue%7B%7B');
expect(outputUrlString).to.not.include('key2=\'a b c\'');
expect(outputUrlString).to.equal('https://postman-echo.com/get?key1={{value}}&key2=%27a%20b%20c%27');
expect(outputUrlString).to.equal('https://postman-echo.com/get?key1={{value}}&key2=%27a%20b+c%27');
});

it('should not encode query params that are already encoded', function () {
Expand Down
Loading