path去除多余“/”和添加“/”正则

function addSlash(src) {
return src.replace(/^(?!/)|(/{2,})/g, '/');
}

addSlash("/d////d");

addSlash("d/d");

addSlash("//d/d");

原文地址:https://www.cnblogs.com/haigelang/p/5411408.html