Comparing version 2.1.2 to 2.1.3
@@ -16,7 +16,2 @@ /*! | ||
// Variable declaration | ||
var BACKSLASH_RE = /\\/g; | ||
var DOT_RE = /\/\.\//g; | ||
var DOUBLE_DOT_RE = /\/[^/]+\/\.\.\//; | ||
var MULTI_SLASH_RE = /([^:/])\/+\//g; | ||
var PROTOCOL_SLASH_RE = /(:)?\/{2,}/; | ||
var toString = Object.prototype.toString; | ||
@@ -83,11 +78,11 @@ var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); | ||
*/ | ||
normalize: function(path) { | ||
normalize: function normalize(path) { | ||
// \a\b\.\c\.\d ==> /a/b/./c/./d | ||
path = path.replace(BACKSLASH_RE, '/'); | ||
path = path.replace(/\\/g, '/'); | ||
// :///a/b/c ==> ://a/b/c | ||
path = path.replace(PROTOCOL_SLASH_RE, '$1//'); | ||
path = path.replace(/(:)?\/{2,}/, '$1//'); | ||
// /a/b/./c/./d ==> /a/b/c/d | ||
path = path.replace(DOT_RE, '/'); | ||
path = path.replace(/\/\.\//g, '/'); | ||
@@ -97,10 +92,23 @@ // @author wh1100717 | ||
// a///b/////c ==> a/b/c | ||
path = path.replace(/([^:/])\/+\//g, '$1/'); | ||
// transfer path | ||
var src = path; | ||
// DOUBLE_DOT_RE matches a/b/c//../d path correctly only if replace // with / first | ||
path = path.replace(MULTI_SLASH_RE, '$1/'); | ||
var DOUBLE_DOT_RE = /([^/]+)\/\.\.(?:\/|$)/g; | ||
// a/b/c/../../d ==> a/b/../d ==> a/d | ||
while (path.match(DOUBLE_DOT_RE)) { | ||
path = path.replace(DOUBLE_DOT_RE, '/'); | ||
} | ||
// a/b/c/../../d ==> a/b/../d ==> a/d | ||
do { | ||
src = src.replace(DOUBLE_DOT_RE, function(matched, dirname) { | ||
return dirname === '..' ? matched : ''; | ||
}); | ||
// break | ||
if (path === src) { | ||
break; | ||
} else { | ||
path = src; | ||
} | ||
} while (true); | ||
// Get path | ||
@@ -117,3 +125,3 @@ return path; | ||
posixURI: function(path) { | ||
return path.replace(BACKSLASH_RE, '/'); | ||
return path.replace(/\\/g, '/'); | ||
}, | ||
@@ -120,0 +128,0 @@ /** |
{ | ||
"name": "file-send", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "A http file send", | ||
@@ -32,3 +32,3 @@ "author": { | ||
"dependencies": { | ||
"ms": "^1.0.0", | ||
"ms": "^2.0.0", | ||
"etag": "^1.8.0", | ||
@@ -35,0 +35,0 @@ "fresh": "^0.5.0", |
@@ -1,6 +0,5 @@ | ||
file-send | ||
========= | ||
# file-send | ||
>A http/https file send | ||
> | ||
>[![NPM Version][npm-image]][npm-url] | ||
@@ -7,0 +6,0 @@ >[![Download Status][download-image]][npm-url] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43302
1215
210