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

De-duplicate forward slashes in relative URLs #42

Open
MadLittleMods opened this issue May 24, 2018 · 2 comments
Open

De-duplicate forward slashes in relative URLs #42

MadLittleMods opened this issue May 24, 2018 · 2 comments

Comments

@MadLittleMods
Copy link

MadLittleMods commented May 24, 2018

De-duplicate/collapse forward slashes when multiple pieces are provided,

Using [email protected]:

  • urlJoin('/', '/') -> '/' ✔️
  • urlJoin('/', '/sub', '/something') -> '/sub/something' ✔️
  • urlJoin('/', '/sub/', '/something') -> '/sub/something' ✔️
  • urlJoin('//', '/something') -> '/something' ✔️
  • urlJoin('/', '/', '/something') -> '//something': ❌ expected '/something'
  • urlJoin('/', '//', '/something') -> '//something': ❌ this isn't my exact use case but I guess this should also be '/something'

Is this behavior expected?

Related issues,

This issue was spawned from https://gitlab.com/gitlab-org/gitlab-selenium-server/merge_requests/10

@LvChengbin
Copy link

For this case, urlJoin('//', '/something') -> '/something, I think it should return '//something' for matching the rule of protocol-relative URL.

@hungtcs
Copy link

hungtcs commented Sep 19, 2022

+1 same issues.

const prefix = '/a';
await import('url-join').then(join => join.default('http://localhost', prefix,  '/swagger'))
// out: 'http://localhost//swagger'
const prefix = '/doc';
await import('url-join').then(join => join.default('http://localhost', prefix,  '/swagger'))
// out: 'http://localhost/doc/swagger'

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