tiny-parse
Advanced tools
Comparing version 2.0.2 to 2.1.0
"use strict"; | ||
const coerce = require("tiny-coerce"), | ||
const tcoerce = require("tiny-coerce"), | ||
each = require("retsu").each, | ||
@@ -15,3 +15,3 @@ url = require("url"); | ||
function queryString (arg = "") { | ||
function queryString (arg = "", coerce = true) { | ||
const result = {}, | ||
@@ -28,3 +28,3 @@ items = arg.replace(/^\?/, "").split("&"); | ||
} else { | ||
item[1] = coerce(decodeURIComponent(item[1])); | ||
item[1] = coerce ? tcoerce(decodeURIComponent(item[1])) : decodeURIComponent(item[1]); | ||
} | ||
@@ -63,3 +63,3 @@ | ||
parsed = url.parse(uri); | ||
parsed.pathname = (parsed.pathname || "").replace(/%20/g, " "); | ||
parsed.pathname = (parsed.pathname || "").replace(/(%20|\+)/g, " "); | ||
parsed.path = parsed.pathname + (parsed.search || ""); | ||
@@ -66,0 +66,0 @@ parsed.query = typeof parsed.search === "string" ? queryString(parsed.search) : {}; |
{ | ||
"name": "tiny-parse", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "URL parsing with coercion of `query`", | ||
@@ -36,5 +36,5 @@ "main": "index.js", | ||
"grunt": "~1.0.1", | ||
"grunt-eslint": "~18.1.0", | ||
"grunt-nsp": "~2.2.0" | ||
"grunt-eslint": "~20.1.0", | ||
"grunt-nsp": "~2.3.1" | ||
} | ||
} |
@@ -15,6 +15,7 @@ # tiny-parse | ||
console.log(parse("/?abc=true").query.abc === true); // true | ||
console.log(parse("/?abc=true", false).query.abc === true); // false | ||
``` | ||
### API | ||
*parse()* | ||
*parse(arg, coerce=true)* | ||
Parses the input, accepts a URL or `http.ClientRequest` | ||
@@ -21,0 +22,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
4784
25