On web pages, resources such as images, css and javascript are loaded by a client's web browser, when embedded with <img>, <link> and <script> tags respectively.
A resource URL can take different forms, it can be a full URL, for example:
http://cdn.mysite.com/images/animage.jpg
It can be a relative path:
images/animage.jpg
../images/animage.jpg
Or just a reference to the root
/images/animage.jpg
How could I create a function in python, that takes the URL of the page, and the URL of a resource on it and ensures that the full URL is returned?
For example:
def resource_url(page,resource):
## if the resource is a full URL, return that
## if not, use the page URL and the resource to return the full URL