Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

query-string

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

query-string - npm Package Compare versions

Comparing version 6.13.5 to 6.13.6

38

index.js

@@ -125,4 +125,6 @@ 'use strict';

return (key, value, accumulator) => {
const isArray = typeof value === 'string' && value.split('').indexOf(options.arrayFormatSeparator) > -1;
const newValue = isArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options);
const isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator);
const isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator));
value = isEncodedArray ? decode(value, options) : value;
const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options);
accumulator[key] = newValue;

@@ -218,3 +220,3 @@ };

function parse(input, options) {
function parse(query, options) {
options = Object.assign({

@@ -236,13 +238,13 @@ decode: true,

if (typeof input !== 'string') {
if (typeof query !== 'string') {
return ret;
}
input = input.trim().replace(/^[?#&]/, '');
query = query.trim().replace(/^[?#&]/, '');
if (!input) {
if (!query) {
return ret;
}
for (const param of input.split('&')) {
for (const param of query.split('&')) {
let [key, value] = splitOnFirst(options.decode ? param.replace(/\+/g, ' ') : param, '=');

@@ -343,3 +345,3 @@

exports.parseUrl = (input, options) => {
exports.parseUrl = (url, options) => {
options = Object.assign({

@@ -349,8 +351,8 @@ decode: true

const [url, hash] = splitOnFirst(input, '#');
const [url_, hash] = splitOnFirst(url, '#');
return Object.assign(
{
url: url.split('?')[0] || '',
query: parse(extract(input), options)
url: url_.split('?')[0] || '',
query: parse(extract(url), options)
},

@@ -361,3 +363,3 @@ options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {}

exports.stringifyUrl = (input, options) => {
exports.stringifyUrl = (object, options) => {
options = Object.assign({

@@ -368,7 +370,7 @@ encode: true,

const url = removeHash(input.url).split('?')[0] || '';
const queryFromUrl = exports.extract(input.url);
const url = removeHash(object.url).split('?')[0] || '';
const queryFromUrl = exports.extract(object.url);
const parsedQueryFromUrl = exports.parse(queryFromUrl, {sort: false});
const query = Object.assign(parsedQueryFromUrl, input.query);
const query = Object.assign(parsedQueryFromUrl, object.query);
let queryString = exports.stringify(query, options);

@@ -379,5 +381,5 @@ if (queryString) {

let hash = getHash(input.url);
if (input.fragmentIdentifier) {
hash = `#${encode(input.fragmentIdentifier, options)}`;
let hash = getHash(object.url);
if (object.fragmentIdentifier) {
hash = `#${encode(object.fragmentIdentifier, options)}`;
}

@@ -384,0 +386,0 @@

{
"name": "query-string",
"version": "6.13.5",
"version": "6.13.6",
"description": "Parse and stringify URL query strings",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc