Find out relative urls in javascript
<p>I want to know if the url is relative or no using javascript. Basically  i will be passed the url, if the url is relative append the current url i.e  minus the file name. Can some one help me with this</p>

<p>eg:- </p>

<blockquote>
  <p><strong>CURRENT URL</strong> = <a href="http://example.com/big/index.html" rel="nofollow">http://example.com/big/index.html</a></p>
  
  <p><strong>PASSED URL 1</strong> = newindex.html<br>
  <strong>OUTPUT</strong> = <a href="http://example.com/big/newindex.html" rel="nofollow">http://example.com/big/newindex.html</a></p>
  
  <p><strong>PASSED URL 2</strong> = <a href="http://mysite.com/big/newindex.html" rel="nofollow">http://mysite.com/big/newindex.html</a><br>
  <strong>OUTPUT</strong> = <a href="http://mysite.com/big/newindex.html" rel="nofollow">http://mysite.com/big/newindex.html</a></p>
</blockquote>
