Skip to content

Latest commit

 

History

History
47 lines (41 loc) · 1.02 KB

url.md

File metadata and controls

47 lines (41 loc) · 1.02 KB

URL

const url = new URL('https://user:pass@dashboard.system.com:5000/login.html?a=1&b=2#top');

The url constant is an object with the following values:

{
  hash: "#top"
  host: "dashboard.system.com:5000"
  hostname: "dashboard.system.com"
  href: "https://user:pass@dashboard.system.com:5000/login.html?a=1&b=2#top"
  origin: "https://dashboard.system.com:5000"
  password: "pass"
  pathname: "/login.html"
  port: "5000"
  protocol: "https:"
  search: "?a=1&b=2"
  searchParams: URLSearchParams {}
  username: "user"
}

Relative URL

const url = new URL('login.html?a=1&b=2#top', 'https://user:pass@dashboard.system.com:5000');
{
  hash: "#top"
  host: "dashboard.system.com:5000"
  hostname: "dashboard.system.com"
  href: "https://user:pass@dashboard.system.com:5000/login.html?a=1&b=2#top"
  origin: "https://dashboard.system.com:5000"
  password: "pass"
  pathname: "/login.html"
  port: "5000"
  protocol: "https:"
  search: "?a=1&b=2"
  searchParams: URLSearchParams {}
  username: "user"
}