How can I determine the url string of an image without a base domain via javascript?
I am collecting data from external url using php and casting it back to my page via ajax to load images. My problem is that the external url has some relative images ("images / example.jpg"), so I need to add my base domain (" http://www.example.com ), so I can load it on my page. The problem is that some of the images contain the url of the base domain, but some are in their relative form. I guess I can use a regex in my javascript to define the string if it has base (" http : //example.domain.com ") or just relative (" images / ") to it.How can I achieve this with a regular expression?
a source to share
You will not be able to distinguish between a relative URL like "images / blank.gif" and a relative URL that has "www.theirdomain.com/images/blank.gif". Who's to say that "www.theirdomain.com" is not a directory?
Unless the url starts with http: //, https: //, or // relative to the url of the page where you pinned them.
a source to share