Return String

Detecting If A URL String Is HTTP

With Regex

Using regex to check if a url string starts with http or https:

/**
 * Checks if a url string starts with http or https
 *
 * @param {string} url url to check protocol for
 * @returns {boolean} true if url is using http or https, false otherwise
 */
function isHttpProtocol(url) {
    return /^https?\:\/\//.test(url);
}