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

Cannot copy request as cURL or generate snippet if host looks invalid #328

Closed
jugaltheshah opened this issue Feb 13, 2019 · 7 comments
Closed
Labels

Comments

@jugaltheshah
Copy link

  • VSCode Version: 1.31.1
  • OS Version: Ubuntu 18.10
  • REST Client Version: 0.21.1

Steps to Reproduce:

  1. Create request to a host that doesn't look valid, e.g. an env var:
POST $URL/service HTTP/1.1
Content-Type: application/json

{
    "name": "test-service",
    "url": "test-service-url"
}
  1. Highlight it
  2. Right click and select "Copy Request As cURL" or "Generate Code Snippet"

Expected behavior:
I'd expect a cURL request equivalent to the one highlighted to be copied to clipboard. Or if "Generate Code Snippet" was chosen, I'd expect the menu of choices to popup

Actual behavior:
Clipboard retains previous contents / no menu pops up.

If I change $URL to http://localhost, for example, it starts working again. Not sure if this is expected behavior, but to me it seems like a bug. IMO REST Client shouldn't be responsible for checking that hosts are valid, only for generating the correct requests per the information given. My use case here was to generate a cURL request for another system in which $URL is valid.

@jugaltheshah
Copy link
Author

Sorry, I believe "Copy Request As cURL" is not working regardless of the host being malformed-looking or not. Possibly related to #308? Though I thought that was one of the fixes for this release.

@Huachao
Copy link
Owner

Huachao commented Feb 14, 2019

@jugaltheshah I can repro the issue and it seems not related to #308. And what's the expected behavior for url $URL/service, should the generated code remain as is like curl -XPOST $URL/service or append the protocol like curl -XPOST http://$URL/service?

@jugaltheshah
Copy link
Author

The expected behavior is that code generated from $URL/service remains as-is, i.e. curl -X POST $URL/service.

@Huachao
Copy link
Owner

Huachao commented Feb 14, 2019

@jugaltheshah I have fixed this issue and will publish this in next release

@Huachao Huachao closed this as completed Feb 14, 2019
@jugaltheshah
Copy link
Author

That's amazing, thanks @Huachao. I don't think I could turn around a sandwich that fast. :)

@Huachao
Copy link
Owner

Huachao commented Mar 6, 2019

@jugaltheshah you can try the latest version 0.21.2 to verify

@jugaltheshah
Copy link
Author

jugaltheshah commented Mar 11, 2019

Sorry for the late reply. Confirmed - with 0.21.2 "Copy Request As cURL" is working as expected with arbitrary (non-url) strings.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants