diff --git a/index.js b/index.js index 1bee463..eac6ce4 100644 --- a/index.js +++ b/index.js @@ -127,18 +127,14 @@ function serveStatic (root, options) { /** * Collapse all leading slashes into a single slash + * + * @param {string} str + * @returns {string} * @private */ -function collapseLeadingSlashes (str) { - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) !== 0x2f /* / */) { - break - } - } - return i > 1 - ? '/' + str.substr(i) - : str +function collapseLeadingSlashes (str) { + return str.replace(/^\/+/, '/') || '/' } /** diff --git a/scripts/version-history.js b/scripts/version-history.js index b8a2b0e..0baecb7 100644 --- a/scripts/version-history.js +++ b/scripts/version-history.js @@ -53,11 +53,5 @@ function repeat (str, length) { } function zeroPad (number, length) { - var num = number.toString() - - while (num.length < length) { - num = '0' + num - } - - return num + return number.toString().padStart(length, '0') }