-3

I am getting some urls from server that contains some images. Some urls start with http and some start with https. I need to check if the url string contain http, then put an s in that string after p, and if it contains https then do nothing.

Abid Khan
  • 2,451
  • 4
  • 22
  • 45

1 Answers1

6
if (urlString.startsWith("http://")) {
    urlString = urlString.replaceFirst("http", "https");
}
Karakuri
  • 38,365
  • 12
  • 84
  • 104