![Check if the given string is an absolute URL](https://javascriptsource.com/wp-content/uploads/2022/03/Check-if-the-given-string-is-an-absolute-URL-702x526.jpg)
Use RegExp.prototype.test()
to test if the string is an absolute URL.
const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str);
// EXAMPLES
isAbsoluteURL('https://google.com'); // true
isAbsoluteURL('ftp://www.myserver.net'); // true
isAbsoluteURL('/foo/bar'); // false