jfromaniello / url-join

Join all arguments together and normalize the resulting url.
MIT License
352 stars 43 forks source link

Port number gets prepended with double slashes #39

Open hrishy opened 6 years ago

hrishy commented 6 years ago

Hi

When using this library If i try urljoin('127.0.0.1:5500' , 'data', 'myfile1.csv');

The output i get is
127.0.0.1://5500/data/myfil1.csv

But the output i am expecting is 127.0.0.1:5500/data/myfil1.csv

Can the library take care of this ?

jfromaniello commented 6 years ago

It used to, this is a bug

hrishy commented 6 years ago

Hi Jose

Appreciate the quick reply . Curious to know if a fix would be provided ?

On Wed, Apr 4, 2018 at 6:20 PM, José F. Romaniello <notifications@github.com

wrote:

It used to, this is a bug

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jfromaniello/url-join/issues/39#issuecomment-378588566, or mute the thread https://github.com/notifications/unsubscribe-auth/AkTiWWC_FK6ITN9vq_f3tye6Oja5vCAIks5tlMGwgaJpZM4TGc97 .

jfromaniello commented 6 years ago

Actually, I am not sure now if we should fix it. For instance url.parse assumes here that 127.0.0.1 is the protocol:

> url.parse('127.0.0.1:23')
Url {
  protocol: '127.0.0.1:',
  slashes: null,
  auth: null,
  host: '23',
  port: null,
  hostname: '23',
  hash: null,
  search: null,
  query: null,
  pathname: null,
  path: null,
  href: '127.0.0.1:23' }

In other words url-join is as broken as url.parse currently.

A solution will be to prepend the protocol:

> urljoin('http://127.0.0.1:5500' , 'data', 'myfile1.csv');
'http://127.0.0.1:5500/data/myfile1.csv'
hrishy commented 6 years ago

Thanks appreciate the "quick" help :)

On Wed, Apr 4, 2018 at 8:05 PM, José F. Romaniello <notifications@github.com

wrote:

Actually, I am not sure now if we should fix it. For instance url.parse assumes here that 127.0.0.1 is the protocol:

url.parse('127.0.0.1:23') Url { protocol: '127.0.0.1:', slashes: null, auth: null, host: '23', port: null, hostname: '23', hash: null, search: null, query: null, pathname: null, path: null, href: '127.0.0.1:23' }

In other words url-join is as broken as url.parse currently.

A solution will be to prepend the protocol:

urljoin('http://127.0.0.1:5500' , 'data', 'myfile1.csv'); 'http://127.0.0.1:5500/data/myfile1.csv'

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jfromaniello/url-join/issues/39#issuecomment-378621977, or mute the thread https://github.com/notifications/unsubscribe-auth/AkTiWbtKlGJhRRSvtGV5cX1Hlnoble1iks5tlNobgaJpZM4TGc97 .

aaronamm commented 2 years ago

@jfromaniello thanks for the solution but it would be nice if we should add this work around in the document. I got this issue when I was working on a local development.

Thanks.