title: get the base URL and file path from my windows URL by using Javascript
body: <p>Hi I tried to get the base URL and file path from my windows URL..But I cant get it..Please correct me..</p>
  <p><strong>The URL is:</strong></p>
  <p><a href="http://sample.com:30023/portal/site/samples/index.jsp" rel="nofollow noreferrer">http://sample.com:30023/portal/site/samples/index.jsp</a></p>
  <p><strong>The current output is:</strong>
  <a href="http://sample.com:30023/index.jsp" rel="nofollow noreferrer">http://sample.com:30023/index.jsp</a>?</p>
  <p><strong>The required output is:</strong>
  <a href="http://sample.com:30023/portal/site/samples/" rel="nofollow noreferrer">http://sample.com:30023/portal/site/samples/</a></p>
  <p><strong>Code used :</strong></p>
  <pre><code>var baseURL = location.protocol + &quot;//&quot; + location.hostname + (location.port &amp;&amp; &quot;:&quot; + location.port) + &quot;/&quot;;
  </code></pre>