Skip to content

Instantly share code, notes, and snippets.

@ZhihaoLau
Created April 10, 2018 17:29
Show Gist options
  • Select an option

  • Save ZhihaoLau/c152a0a35ef6f11f32f9e5716d494352 to your computer and use it in GitHub Desktop.

Select an option

Save ZhihaoLau/c152a0a35ef6f11f32f9e5716d494352 to your computer and use it in GitHub Desktop.

Revisions

  1. ZhihaoLau created this gist Apr 10, 2018.
    17 changes: 17 additions & 0 deletions parseUrl.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    export function parseUrl(url) {
    let a = document.createElement('a')
    a.href = url

    return {
    href: a.href,
    protocol: a.protocol,
    host: a.host,
    hostname: a.hostname,
    port: a.port,
    pathname: a.pathname,
    search: a.search,
    hash: a.hash,
    origin: a.origin
    }
    }