fast-url-parser
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"name": "fast-url-parser", | ||
"description": "Extremely fast implementation of node core url library", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "fast", |
@@ -21,2 +21,4 @@ #Introduction | ||
You may disable automatic escaping of some characters when parsing an URL by passing `true` as a forth argument so that: `url.format(url.parse(yourUrl, false, false, true)) == yourUrl` | ||
Example: | ||
@@ -23,0 +25,0 @@ |
@@ -48,3 +48,3 @@ "use strict"; | ||
Url.prototype.parse = | ||
function Url$parse(str, parseQueryString, hostDenotesSlash) { | ||
function Url$parse(str, parseQueryString, hostDenotesSlash, disableAutoEscapeChars) { | ||
if (typeof str !== "string") { | ||
@@ -77,12 +77,12 @@ throw new TypeError("Parameter 'url' must be a string, not " + | ||
if (ch === 0x2F /*'/'*/ || ch === 0x5C /*'\'*/) { | ||
this._parsePath(str, start, end); | ||
this._parsePath(str, start, end, disableAutoEscapeChars); | ||
} | ||
else if (ch === 0x3F /*'?'*/) { | ||
this._parseQuery(str, start, end); | ||
this._parseQuery(str, start, end, disableAutoEscapeChars); | ||
} | ||
else if (ch === 0x23 /*'#'*/) { | ||
this._parseHash(str, start, end); | ||
this._parseHash(str, start, end, disableAutoEscapeChars); | ||
} | ||
else if (this._protocol !== "javascript") { | ||
this._parsePath(str, start, end); | ||
this._parsePath(str, start, end, disableAutoEscapeChars); | ||
} | ||
@@ -692,4 +692,4 @@ else { //For javascript the pathname is just the rest of it | ||
var ret = ""; | ||
var autoEscapeMap = isAfterQuery | ||
? this._afterQueryAutoEscapeMap : this._autoEscapeMap; | ||
var autoEscapeMap = isAfterQuery ? | ||
this._afterQueryAutoEscapeMap : this._autoEscapeMap; | ||
for (; i <= end; ++i) { | ||
@@ -710,3 +710,3 @@ var ch = str.charCodeAt(i); | ||
Url.prototype._parsePath = | ||
function Url$_parsePath(str, start, end) { | ||
function Url$_parsePath(str, start, end, disableAutoEscapeChars) { | ||
var pathStart = start; | ||
@@ -720,3 +720,3 @@ var pathEnd = end; | ||
if (ch === 0x23 /*'#'*/) { | ||
this._parseHash(str, i, end); | ||
this._parseHash(str, i, end, disableAutoEscapeChars); | ||
pathEnd = i - 1; | ||
@@ -726,7 +726,7 @@ break; | ||
else if (ch === 0x3F /*'?'*/) { | ||
this._parseQuery(str, i, end); | ||
this._parseQuery(str, i, end, disableAutoEscapeChars); | ||
pathEnd = i - 1; | ||
break; | ||
} | ||
else if (!escape && autoEscapeCharacters[ch] === 1) { | ||
else if (!disableAutoEscapeChars && !escape && autoEscapeCharacters[ch] === 1) { | ||
escape = true; | ||
@@ -751,3 +751,3 @@ } | ||
Url.prototype._parseQuery = function Url$_parseQuery(str, start, end) { | ||
Url.prototype._parseQuery = function Url$_parseQuery(str, start, end, disableAutoEscapeChars) { | ||
var queryStart = start; | ||
@@ -762,7 +762,7 @@ var queryEnd = end; | ||
if (ch === 0x23 /*'#'*/) { | ||
this._parseHash(str, i, end); | ||
this._parseHash(str, i, end, disableAutoEscapeChars); | ||
queryEnd = i - 1; | ||
break; | ||
} | ||
else if (!escape && autoEscapeCharacters[ch] === 1) { | ||
else if (!disableAutoEscapeChars && !escape && autoEscapeCharacters[ch] === 1) { | ||
escape = true; | ||
@@ -787,3 +787,3 @@ } | ||
Url.prototype._parseHash = function Url$_parseHash(str, start, end) { | ||
Url.prototype._parseHash = function Url$_parseHash(str, start, end, disableAutoEscapeChars) { | ||
if (start > end) { | ||
@@ -793,3 +793,5 @@ this.hash = ""; | ||
} | ||
this.hash = this._getComponentEscaped(str, start, end, true); | ||
this.hash = disableAutoEscapeChars ? | ||
str.slice(start, end + 1) : this._getComponentEscaped(str, start, end, true); | ||
}; | ||
@@ -884,6 +886,6 @@ | ||
Url.parse = function Url$Parse(str, parseQueryString, hostDenotesSlash) { | ||
Url.parse = function Url$Parse(str, parseQueryString, hostDenotesSlash, disableAutoEscapeChars) { | ||
if (str instanceof Url) return str; | ||
var ret = new Url(); | ||
ret.parse(str, !!parseQueryString, !!hostDenotesSlash); | ||
ret.parse(str, !!parseQueryString, !!hostDenotesSlash, !!disableAutoEscapeChars); | ||
return ret; | ||
@@ -890,0 +892,0 @@ }; |
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
37673
915
85