bruno icon indicating copy to clipboard operation
bruno copied to clipboard

Omitting the protocol does not work for localhost with port

Open BlueIce opened this issue 1 year ago • 1 comments

A while back a new feature was introduced which allows making requests without specifying the protocol (http://).

Unfortunately when creating a request with localhost:8080 I get the following error:

Error invoking remote method 'send-http-request': AxiosError: Unsupported protocol localhost:

On the other hand the following requests don't give this error:

  • localhost
  • 127.0.0.1
  • 127.0.0.1:8080
  • example.com
  • example.com:8080

It seems there is something special going on with localhost in combination with explicitly specifying a port.

System information bruno 1.9.0 on Windows 11

Related issues/PRs I found

  • #946
  • #1070
  • #1102

BlueIce avatar Feb 25 '24 10:02 BlueIce

I've had the same problem. I think it related to #1153 pr. When I change protocolRegex(regex expression) to the original, nothing errors happen

// #1153 pr - same with axios protocol
const protocolRegex = /^([-+\w]{1,25})(:?\/\/|:)/;

// #1102 pr - original
const protocolRegex = /([a-zA-Z]{2,20}:\/\/)(.*)/;

// current - result is false (localhost)
 if (!protocolRegex.test(request.url)) { 
    request.url = `http://${request.url}`; 
  }
image

jokj624 avatar Mar 18 '24 02:03 jokj624

@helloanoop This issue is caused by #1153 causing major QoL issues. We can either revert that commit or add a condition to check if format is localhost:port which can then be modified to something mentioned here https://stackoverflow.com/a/73166977

I can do these modifications if you permit.

gtlsgamr avatar Jun 24 '24 10:06 gtlsgamr