I have a js function which receives a url like:
http://example.com/folder1/folder2/../page.html
Note that the url is absolute, but it has ../
in the middle so the actual html page it points to, lives in folder1
instead of folder2
.
How can I convert http://example.com/folder1/folder2/../page.html
into http://example.com/folder1/page.html
?
Note that my url may contain multiple pieces of ../
Is there a built-in facility in Javascript for this ? (for ex: in C# I would run it through URI class which does this for me.)
UPDATE: to clarify a bit, I do not want to create or use a DOM element for this.