-
Notifications
You must be signed in to change notification settings - Fork 346
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
HTTP code generation doesn't handle variables in URL correctly #315
Comments
I'll like to work on this! Could you please assign it to me? |
On the application, I noticed this is a general issue and not just with
The If this sounds right, should I open an issue on the postman-collection repo? |
@VallariAg Yes seems like it, I observed the same behavior. Able to reproduce this in
@codenirvana Thoughts? |
@umeshp7 If your use case requires replacing variables in a parsed URL object, always: |
@codenirvana The logic for replacing the variables isn't in code-generators, we use the information directly provided to us in the sdk's url object. https://github.com/postmanlabs/postman-code-generators/blob/develop/codegens/http/lib/util.js#L170 |
@codenirvana We are getting wrong url from Runtime when the URL starts with a variable. This is the url object that is passed to the code-generator:
As you can see it is taking the value of the variable as Host and the rest as path. |
@umeshp7 @webholik If you are resolving variables in a URL (not sure how it's done in code-gen) you have to parse it again. So, if the input source is not guaranteed to provide a proper parsed URL, I suggest always parsing it again in the code generator. |
Describe the bug
The HTTP code generator, when given a URL starting with a variable like
{{my_base_url}}/path
, generates code likeNote the host header incorrectly includes both the scheme and part of the path, while the actual path is incomplete
Expanding the variable in manually causes the generator to give the correct output
To Reproduce
Steps to reproduce the behavior:
my_base_url
variable tohttps://example.com/base
{{my_base_url}}/path
Screenshots
For example you could add the screenshot of the snippet/request builder from Postman app.
The text was updated successfully, but these errors were encountered: