remove duplicate forward slashes from the URL

后端 未结 4 1808
南方客
南方客 2021-01-04 03:34

How can I remove duplicate forward slashes from the a url, but keep the // which comes after http: so that the URL does not break.

http://localh         


        
4条回答
  •  伪装坚强ぢ
    2021-01-04 03:50

    You can use:

    abc.replace(/([^:]\/)\/+/g, "$1");
    

    Working Demo

    Update: Already answered by Halcyon

提交回复
热议问题