We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9a94734 + af7cd7b commit fbf723bCopy full SHA for fbf723b
index.js
@@ -127,18 +127,14 @@ function serveStatic (root, options) {
127
128
/**
129
* Collapse all leading slashes into a single slash
130
+ *
131
+ * @param {string} str
132
+ * @returns {string}
133
* @private
134
*/
-function collapseLeadingSlashes (str) {
- for (var i = 0; i < str.length; i++) {
- if (str.charCodeAt(i) !== 0x2f /* / */) {
135
- break
136
- }
137
138
139
- return i > 1
140
- ? '/' + str.substr(i)
141
- : str
+function collapseLeadingSlashes (str) {
+ return str.replace(/^\/+/, '/') || '/'
142
}
143
144
0 commit comments