usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.6k stars 1.27k forks source link

Extra Slash (`//`) in Generated API URL Causes Invalid Request #3421

Open stephane-archer opened 2 weeks ago

stephane-archer commented 2 weeks ago

I have checked the following:

Describe the bug

baseUrl: http://localhost:80/
API call is: {{baseUrl}}/transcode-video

the API call has been imported from an OpenAPI spec where each path must start with / to be valid according to the specification the generated curl code is:

curl --request POST \
  --url http://localhost//transcode-video \
  --header 'content-type: multipart/form-data' \
  --form videoCodec=H.264 \
  --form height=500 \
  --form width=600 \
  --form originalVideoFile=@/Users/fractale/Desktop/proxy_test/a.mov

this request is not working because of the // in the URL

I'm not sure if the issue is in the code generator, not removing the // or the OpenAPI importer to import the / from the path or my baseUrl to include a / (it's the default value)

.bru file to reproduce the bug

No response

Screenshots/Live demo link

Screenshot 2024-11-05 at 10 13 57 Screenshot 2024-11-05 at 10 13 32 Screenshot 2024-11-05 at 10 13 47
anusree-bruno commented 2 weeks ago

Hi @stephane-archer , It looks like the issue is due to a trailing / at the end of the base URL, causing the request to be http://localhost:80//transcode-video instead of http://localhost:80/transcode-video. The problem is with the openapi import, you can refer to issue #3116 for more details.

We'll work on a fix for this soon. In the meantime, you can manually update the baseUrl in your environment settings to resolve it.

stephane-archer commented 2 weeks ago

Thanks for pointing out the issue I will update my baseUrl

The open API import is not working properly but, additionally, removing the trailing ˋ/ˋ automatically from baseUrl or "sanitizing" the URL by removing // by ˋ/` could be a good idea too.

What are your thoughts on this?