Implemented resolveUrl

I know, the code does not look nice but it passes the current test cases. :)