How to generate correct url for window.location.href?
<p>How to generate correct url for window.location.href in the following two scenarios:</p>

<ol>
<li>current url is <a href="http://example.com:8080/something/" rel="nofollow">http://example.com:8080/something/</a></li>
<li>current url is <a href="http://example.com:8080/something/something-else/" rel="nofollow">http://example.com:8080/something/something-else/</a></li>
</ol>

<p>target url is <a href="http://example.com:8080/something/something-new/" rel="nofollow">http://example.com:8080/something/something-new/</a>.</p>

<p>Ideally I would like to have the same code for both scenarios and <a href="http://example.com:8080/something/" rel="nofollow">http://example.com:8080/something/</a> should not be hardcoded.</p>
