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

WHATWG-URL may not display poperly #36337

Closed
tkoelpin opened this issue Dec 1, 2020 · 1 comment
Closed

WHATWG-URL may not display poperly #36337

tkoelpin opened this issue Dec 1, 2020 · 1 comment
Labels
wrong repo Issues that should be opened in another repository.

Comments

@tkoelpin
Copy link

tkoelpin commented Dec 1, 2020

  • Version: 15.3.0
  • Platform: Windows 64-bit
  • Subsystem: WHATWG-URL

What steps will reproduce the bug?

const url = require('url');
let href = new URL('https://127.0.0.1/v1/users?');
console.log(href);

How often does it reproduce? Is there a required condition?

It does reproduce every single time.

What is the expected behavior?

I really expect that the URL contains in the search-attribute a single question mark.

URL {
  href: 'https://127.0.0.1/v1/users?',
  origin: 'https://127.0.0.1',
  protocol: 'https:',
  username: '',
  password: '',
  host: '127.0.0.1',
  hostname: '127.0.0.1',
  port: '',
  pathname: '/v1/users',
  search: '?',
  searchParams: URLSearchParams {},
  hash: ''
}

What do you see instead?

I see instead the search-attribute with an empty string.

URL {
  href: 'https://127.0.0.1/v1/users?',
  origin: 'https://127.0.0.1',
  protocol: 'https:',
  username: '',
  password: '',
  host: '127.0.0.1',
  hostname: '127.0.0.1',
  port: '',
  pathname: '/v1/users',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}

Additional information

I need this missing feature for my automated API testing.

@aduh95
Copy link
Contributor

aduh95 commented Dec 1, 2020

I think this is working as expected. See https://url.spec.whatwg.org/#dom-url-search:

If this’s URL’s query is either null or the empty string, then return the empty string.

If you want this behaviour to change, you'd need to open an issue to https://github.com/whatwg/url. If your suggestion is adopted by the spec, it will be implemented by Node.js as well as other browsers.

@aduh95 aduh95 closed this as completed Dec 1, 2020
@aduh95 aduh95 added the wrong repo Issues that should be opened in another repository. label Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wrong repo Issues that should be opened in another repository.
Projects
None yet
Development

No branches or pull requests

2 participants