I\'m in a situation where I need to rewrite an url in javascript and switch it from http protocol to https.
I can match https urls with:
if(url.match(\'
Replace directly with a regex :
url = url.replace(/^http:\/\//i, 'https://');