Rewriting HTTP url to HTTPS using regular expression and javascript
Cannot it be done by simply replacing the http string?
if(url.match('^http://')){
url = url.replace("http://","https://")
}
Replace directly with a regex :
url = url.replace(/^http:\/\//i, 'https://');