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

Curl import changes URL #2379

Closed
2 tasks done
allanf181 opened this issue May 29, 2024 · 6 comments · Fixed by #2793
Closed
2 tasks done

Curl import changes URL #2379

allanf181 opened this issue May 29, 2024 · 6 comments · Fixed by #2793
Labels
bug Something isn't working

Comments

@allanf181
Copy link

I have checked the following:

  • I use the newest version of bruno.
  • I've searched existing issues and found nothing related to my issue.

Describe the bug

When a curl command is imported, the url is changed by removing the last /
curl 'http://example.com/test/' turns into http://example.com/test

This affects endpoints that end with /

.bru file to reproduce the bug

No response

Screenshots/Live demo link

Bruno_bLISVj39uA.mp4
@allanf181 allanf181 added the bug Something isn't working label May 29, 2024
@satokenta940
Copy link

When you import cURL from Apidog, you won't encounter this issue. Give it a try; I think it's quite effective.

@jokj624
Copy link
Contributor

jokj624 commented Jun 17, 2024

requestJson.url = request.urlWithoutQuery.replace(/\/$/, '');

Maybe it's removed by this line.
However, is there a case where it only works when there is a '/' at the end of the url?

@jwetzell
Copy link
Contributor

@jokj624 that line is actually specifically written to remove the / from the end of a url. So seems like they are intentionally stripping of that last backslash for some reason. Not sure why the raw_url field also gets the processed value. That does not seem "raw" to me.

@jkjustjoshing
Copy link

I can't imagine a situation in which I want the request that Bruno sends out to be different from the request cURL sends out. If the user doesn't want a trailing slash they would just delete it from the URL after import (or in the cURL command).

This caused me a huge headache yesterday. I was trying to hit this Python FastAPI endpoint, and I was getting a correct response using cURL on the command line, but importing into Bruno kept giving me a "405 method not allowed" error.

image

I ended up spinning up a webserver that echoed back the headers, thinking maybe Bruno was attaching a hidden header somewhere? I thought it would be great if Bruno had an "export to cURL" feature, so I could have done a string comparison with the cURL syntax, but I don't believe that exists in Bruno.

15 minutes later, I realized that the trailing / was being stripped off.

@jkjustjoshing
Copy link

@helloanoop do you remember why you chose to strip the trailing slash?

Its-treason added a commit to Its-treason/bruno that referenced this issue Jul 30, 2024
@helloanoop
Copy link
Contributor

No, I don't remember. Agree that we should not strip the slash if curl command has it.
@sanjai0py Can you raise a PR for this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants