query-string
Advanced tools
Comparing version 6.1.0 to 6.2.0
27
index.js
@@ -126,2 +126,3 @@ 'use strict'; | ||
} | ||
return input.slice(queryStart + 1); | ||
@@ -175,17 +176,20 @@ } | ||
exports.stringify = (obj, options) => { | ||
const defaults = { | ||
if (!obj) { | ||
return ''; | ||
} | ||
options = Object.assign({ | ||
encode: true, | ||
strict: true, | ||
arrayFormat: 'none' | ||
}; | ||
}, options); | ||
options = Object.assign(defaults, options); | ||
const formatter = encoderForArrayFormat(options); | ||
const keys = Object.keys(obj); | ||
if (options.sort === false) { | ||
options.sort = () => {}; | ||
if (options.sort !== false) { | ||
keys.sort(options.sort); | ||
} | ||
const formatter = encoderForArrayFormat(options); | ||
return obj ? Object.keys(obj).sort(options.sort).map(key => { | ||
return keys.map(key => { | ||
const value = obj[key]; | ||
@@ -216,6 +220,11 @@ | ||
return encode(key, options) + '=' + encode(value, options); | ||
}).filter(x => x.length > 0).join('&') : ''; | ||
}).filter(x => x.length > 0).join('&'); | ||
}; | ||
exports.parseUrl = (input, options) => { | ||
const hashStart = input.indexOf('#'); | ||
if (hashStart !== -1) { | ||
input = input.slice(0, hashStart); | ||
} | ||
return { | ||
@@ -222,0 +231,0 @@ url: input.split('?')[0] || '', |
{ | ||
"name": "query-string", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"description": "Parse and stringify URL query strings", | ||
@@ -41,7 +41,7 @@ "license": "MIT", | ||
"devDependencies": { | ||
"ava": "*", | ||
"ava": "^0.25.0", | ||
"deep-equal": "^1.0.1", | ||
"fast-check": "^1.0.1", | ||
"xo": "*" | ||
"fast-check": "^1.5.0", | ||
"xo": "^0.23.0" | ||
} | ||
} |
@@ -18,3 +18,3 @@ # query-string [![Build Status](https://travis-ci.org/sindresorhus/query-string.svg?branch=master)](https://travis-ci.org/sindresorhus/query-string) | ||
This module targets Node.js 6 or later and the latest version of Chrome, Firefox, and Safari. If you want support for older browsers, use version 5: `npm install query-string@5`. | ||
This module targets Node.js 6 or later and the latest version of Chrome, Firefox, and Safari. If you want support for older browsers, or, [if your project is using create-react-app](https://github.com/sindresorhus/query-string/pull/148#issuecomment-399656020), use version 5: `npm install query-string@5`. | ||
@@ -21,0 +21,0 @@ <a href="https://www.patreon.com/sindresorhus"> |
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
13068
185