Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I tried to use the Given solutions, the Chosen one was an overkill for my purpose and "Creating a element" one messes up for me.</p> <p>It's not ready for Port in URL yet. I hope someone finds it useful</p> <pre><code>function parseURL(url){ parsed_url = {} if ( url == null || url.length == 0 ) return parsed_url; protocol_i = url.indexOf('://'); parsed_url.protocol = url.substr(0,protocol_i); remaining_url = url.substr(protocol_i + 3, url.length); domain_i = remaining_url.indexOf('/'); domain_i = domain_i == -1 ? remaining_url.length - 1 : domain_i; parsed_url.domain = remaining_url.substr(0, domain_i); parsed_url.path = domain_i == -1 || domain_i + 1 == remaining_url.length ? null : remaining_url.substr(domain_i + 1, remaining_url.length); domain_parts = parsed_url.domain.split('.'); switch ( domain_parts.length ){ case 2: parsed_url.subdomain = null; parsed_url.host = domain_parts[0]; parsed_url.tld = domain_parts[1]; break; case 3: parsed_url.subdomain = domain_parts[0]; parsed_url.host = domain_parts[1]; parsed_url.tld = domain_parts[2]; break; case 4: parsed_url.subdomain = domain_parts[0]; parsed_url.host = domain_parts[1]; parsed_url.tld = domain_parts[2] + '.' + domain_parts[3]; break; } parsed_url.parent_domain = parsed_url.host + '.' + parsed_url.tld; return parsed_url; } </code></pre> <hr> <p>Running this:</p> <pre><code>parseURL('https://www.facebook.com/100003379429021_356001651189146'); </code></pre> <p>Result:</p> <pre><code>Object { domain : "www.facebook.com", host : "facebook", path : "100003379429021_356001651189146", protocol : "https", subdomain : "www", tld : "com" } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload