Undefined pathname in js
<p>I am trying to extract the base of the url:</p>

<pre><code>http://google.com/something --&gt; http://google.com
http://127.0.0.1:8000/something --&gt; http://127.0.0.1:8000
</code></pre>

<p>When I try and use the following:</p>

<pre><code>var pathArray = window.location.pathname;
alert(pathArray);
</code></pre>

<p>I get <code>pathArray = undefined</code>. Note: using <code>location.hostname</code> does work here. Why is <code>.pathname</code> returning undefined, and how would I get the url base here? Thank you.</p>

<p><strong>Update</strong>: I used <code>var pathArray = 'http://' + window.location</code>.</p>
