JSFiddle - React, Tailwind, and code Playground

by pseudosavant

HTML

<div id="log"><div>

JavaScript

var log = function(msg) {
    document.getElementById("log").innerHTML += msg + "<br/>";
};

var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";

log("protocol: " + parser.protocol); // => "http:"
log("hostname: " + parser.hostname); // => "example.com"
log("port: " + parser.port); // => "3000"
log("pathname: " + parser.pathname); // => "/pathname/"
log("search: " + parser.search); // => "?search=test"
log("hash: " + parser.hash); // => "#hash"
log("host: " + parser.host); // => "example.com:3000"