str = "http://example.com"; str = str.replace("http://", "https://"); console.log(str); // "https://example.com"
正規表現で先頭だけでも良いかも