Should I expect any pitfalls if I would simple do this
function absoluteOrRelative(url)
{
return url.indexOf(":") === -1 ? "relative" : "absolute";
}
The reason I ask is that I am uncertain if there is any way in which a colon character :
might also occur in a relative URL?
Some URLs contain a so called "URI schemas", such as data:
,ftp:
,mailto:
,blob:
,file"
, and many more. While I feel uncertain if all of the possible schemas really imply the meaning of what constitues an URL, I would hope that the above code does "work", as any absolute URL to the most common http
, https
, file:
schemas seems to be dealt with appropriately as well.