How can you determine whether a string is a local path or a reference to another server?
For example, with the following list of URLs how can I determine which ones are in reference to the local file path or to example.com?
var paths = [
'foo/bar.css',
'/bar/foo.css',
'//cdn.example.com/monkey.css',
'https://example.com/banana.css'
];
I've looked into the url
npm package, however it cannot parse the third path into an object containing the host.
What I'm trying to do is extract all of the CSS information from the page, as well as from linked stylesheets, using a utility that knows the page URL alone. I need to know where to send subsequent requests, either to the original host, or some other one such as example.com