question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate slashes "//" in urls when a part is empty

See original GitHub issue

url-join version 3.0.0

> urlJoin('path/', '', '/test')
'path/test'  # expected
'path//test' # actual

> urlJoin('path', '', /test')
'path/test'  # expected
'path//test' # actual

> urlJoin('path', null, /test')
'path/test'  # expected
'path//test' # actual

In more detail, I’ve got an array of bits of a url. Sometimes, parts are optional, so I set them to ‘’ and assume the url joiner will throw away the empty bits

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
crccheckcommented, Feb 28, 2018

ooh, I didn’t even think of that use case. I’ll try to keep that in mind in the future too. For reference, here’s Node’s path.join with some variations of that case:

> path.join('', 'foo.js')
'foo.js'
> path.join('', '/foo.js')
'/foo.js'
> path.join('/', 'foo.js')
'/foo.js'
> path.join('/', '/foo.js')
'/foo.js'
1reaction
jfromaniellocommented, Feb 2, 2018

Thanks for reporting this. I just published v4 addressing this the same way that path.join does.

Read more comments on GitHub >

github_iconTop Results From Across the Web

url with multiple forward slashes, does it break anything?
I have a script that parses URLs and i was wondering if it would break anything (or change the path) if i replaced...
Read more >
What does a double slash in the URL path mean?
This will issue a HTTP 301 Moved Permanently redirect so that any double slashes are stripped out of the URL.
Read more >
Why is there no error when I enter many slashes in a file URL ...
RFC3986, section 3.3 says multiple slashes are valid in URLs. The / in a URL determines where segments of the URL are split....
Read more >
Trailing Slashes on URLs: Contentious or Settled? | CSS-Tricks
If you render the same content, both with and without a trailing slash, that's theoretically a duplicate content penalty and a no-no.
Read more >
Should You Have a Trailing Slash at the End of URLs? - Ahrefs
These URLs are treated exactly the same and it doesn't matter which version you use. Trailing slashes matter for other URLs. domain.com/page ≠ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found