title: Document.referrer for base domain
body: <p>I know I can grab the entire referring url by using:</p>
  
  <pre><code>document.referrer
  </code></pre>
  
  <p>But how would I only grab the base domain of the referrer??  So:</p>
  
  <pre><code>if(document.referrer === subdomain.domain.com){
  
  }
  </code></pre>
  
  <p>So all referring urls coming from that main domain would work and all strings coming after the base domain are ignored.</p>