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

Port number gets prepended with double slashes #39

Open
hrishy opened this issue Apr 4, 2018 · 5 comments
Open

Port number gets prepended with double slashes #39

hrishy opened this issue Apr 4, 2018 · 5 comments

Comments

@hrishy
Copy link

hrishy commented Apr 4, 2018

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
Copy link
Owner

It used to, this is a bug

@hrishy
Copy link
Author

hrishy commented Apr 4, 2018 via email

@jfromaniello
Copy link
Owner

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
Copy link
Author

hrishy commented Apr 4, 2018 via email

@aaronamm
Copy link

aaronamm commented Jul 5, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants