Correcting string replacement algorithm

String replacement to correct additional '/' introduced in the url is not working correctly. 
Since "//" is being replaced in the previous line, the line 37 never executes leaving the / in front of http. 
My quick and simple suggestion is to remove one of the / in the patterns. It works fine with that.
Otherwise there is a malformed url error.