replaced encodeURI with sdk.Url, issue #435#437
replaced encodeURI with sdk.Url, issue #435#437ShauryaAg wants to merge 12 commits intopostmanlabs:developfrom
Conversation
|
One of test in golang is failing because the generated code snippet includes Can someone help me with this? @webholik |
|
Made a few changes in test files as mentioned in #438 |
codegens/golang/lib/index.js
Outdated
| codeSnippet += `func main() {\n\n${indent}url := "${encodeURI(request.url.toString())}"\n`; | ||
| finalUrl = new sdk.Url(request.url.toString()); | ||
| // URL encoding each part of Url individually | ||
| finalUrl = `${finalUrl.protocol}://${finalUrl.getRemote()}${finalUrl.getPathWithQuery(true)}`; |
There was a problem hiding this comment.
A url may not have protocol present. For example if the url is postman.com/post, then finalURL.protocol will return undefined and the finalUrl will be undefined://postman.com/post which is invalid.
Infact I don't see why we need to manually construct the final URL. url.toString() does that for us.
There was a problem hiding this comment.
Ah, sorry. I was unfamiliar with url.toString(). I will make a necessary changes as soon as possible.
|
@webholik I have made the necessary changes, however |
|
@webholik the test fails as it doesn't URL encode I think a better approach would be to parse URLs using Something like |
Replaced
encodeURIfunction withsdk.Url(urlString)frompostman-collectionto parse the URL