If you don't know the current URL, you can't of course determine the absolute URL of any relative URL. For instance, ../foo.html will have a different absolute URL if found on www.mysite.com (www.mysite.com/foo.html), www.mysite.com/mypath (www.mysite.com/foo.html) or www.mysite.com/mypath/mysubpath (www.mysite.com/mypath/foo.html).
So your first step is: determine the full current URL, or you can't do a single thing. If you don't know the domain, you can actually add any domain and later cut it off again. "localhost" tends to be a good one
subject: how to constract absolute URL from relative URL string