New class URL and API::getDestinationURL()
For a while now, many parts of library relied on function API::getDestinationURL($page). This function returns the valid URL which will point to specified page. However the implementation of this function was only working for absolute page names, and was built-in into API.
I am adding implementation which relies on a new class called URL. This class instance will be returned by getDestinationURL(). If you happen to pass this object to getDestinationURL again, it will not going to mess up the URL anymore.
Apart from that – additional syntax for relative pages is now allowed.
- pagename – will link to absolute page /pagename
- /pagename – same as above
- ./pagename – will link to a relative page. If our current page is users/add, then link will point to users/pagename
- ../pagename – will go one level up. You can use ../users to return from users/add to list of users.
URL generation supports sticky arguments and will also properly determine base URL. The returned URL will be absolute with “http://” (or https) in front.