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

hurlfmt: accept 'Copy as cURL' from Chrome as it #3615

Closed
jcamiel opened this issue Jan 20, 2025 · 6 comments · Fixed by #3712
Closed

hurlfmt: accept 'Copy as cURL' from Chrome as it #3615

jcamiel opened this issue Jan 20, 2025 · 6 comments · Fixed by #3712
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented Jan 20, 2025

When using "Copy as cURL" from Chrome, we can get this kind of curl command:

curl 'https://hurl.dev/humans.txt' \
  -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \
  -H 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' \
  -H 'cache-control: no-cache' \
  -H 'pragma: no-cache' \
  -H 'priority: u=0, i' \
  -H 'sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: document' \
  -H 'sec-fetch-mode: navigate' \
  -H 'sec-fetch-site: none' \
  -H 'sec-fetch-user: ?1' \
  -H 'upgrade-insecure-requests: 1' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'

Using this as an input to hurlfmt to convert this curl command to an Hurl file raises an error due to the backslash escape:

$ hurlfmt --in curl /tmp/curl.txt 
error: Can not parse curl command at line 1: Invalid escape at column 37

Note: in Firefox, there is no backslash

curl 'https://hurl.dev/humans.txt' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'Sec-Fetch-Dest: document' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Site: cross-site' -H 'Priority: u=0, i' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: trailers'
@jcamiel jcamiel added enhancement New feature or request good first issue Good for newcomers labels Jan 20, 2025
@jcamiel jcamiel changed the title hurlfmt: accept 'Copy as curl' from Chrome as it hurlfmt: accept 'Copy as cURL' from Chrome as it Jan 20, 2025
@ilyaaay
Copy link
Contributor

ilyaaay commented Jan 20, 2025

Hi. I want to take this issue.

@jcamiel
Copy link
Collaborator Author

jcamiel commented Jan 20, 2025

Go @ilyaaay

@ikorason
Copy link
Contributor

ikorason commented Feb 6, 2025

hey @ilyaaay r u still working on this? if not would you mind I take a look?

@ilyaaay
Copy link
Contributor

ilyaaay commented Feb 7, 2025

@ikorason Hi. Yeah. I'm working with this issue. It need complex refactor

@ikorason
Copy link
Contributor

ikorason commented Feb 7, 2025

@ilyaaay if its ok with you, I have a fix where there is no complex refactor involved

@jcamiel please check
#3712

@jcamiel
Copy link
Collaborator Author

jcamiel commented Feb 7, 2025

Yes it's looks OK. Unless mistaken, I don't see any needs to change it more,

@jcamiel jcamiel linked a pull request Feb 7, 2025 that will close this issue
@jcamiel jcamiel added this to the 6.1.0 milestone Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants