diff --git a/index.js b/index.js index 1bee463..4259d1f 100644 --- a/index.js +++ b/index.js @@ -127,17 +127,15 @@ function serveStatic (root, options) { /** * Collapse all leading slashes into a single slash + * @param {string} str * @private */ function collapseLeadingSlashes (str) { - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) !== 0x2f /* / */) { - break - } - } + let i + for (i = 0; i < str.length && str.charCodeAt(i) === 0x2f; i++); return i > 1 - ? '/' + str.substr(i) + ? '/' + str.slice(i) : str }