-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,371
  • 3
  • 19
  • 44

1 Answers1

5
if (urlString.startsWith("http://")) {
    urlString = urlString.replaceFirst("http", "https");
}
Karakuri
  • 37,627
  • 12
  • 79
  • 103