Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
search-params
Advanced tools
A module to manipulate search part of URLs (querystring). Created to externalise some code shared by path-parser and route-node.
Parse a querystring and returns an object of parameters. See options below for available options.
Build a querystring from a list of parameters
Remove a list of parameters (names) from a querystring, and returns an object containing removedParams
and querystring
.
Keep a list of parameters (names) from a querystring, and returns an object containing keptParams
and querystring
.
All options are optional.
arrayFormat
: Specifies how arrays should be stringified
'none'
(default): no brackets or indexes are added to query parameter names ('role=member&role=admin'
)'brackets
: brackets are added to query parameter names ('role[]=member&role[]=admin'
)'index
: brackets and indexes are added to query parameter names ('role[0]=member&role[1]=admin'
)booleanFormat
: specifies how boolean values are stringified and parsed
'none'
(default): booleans are stringified to strings ('istrue=true&isfalse=false'
)'empty-true'
: same as 'none'
except true values are stringified without value ('istrue&isfalse=false'
). If you choose this boolean format, make sure to change the value of 'nullFormat'
.'string'
: as above but 'true'
and 'false'
are parsed as booleans'unicode
: true
and false
are displayed with unicode characters, and parsed as booleans ('istrue=✓&isfalse=✗'
)nullFormat
: specifies how null values are stringified and parsed
'default'
(default): null values are stringified without equal sign and value ('isnull'
)'string'
: null values are stringified to 'null'
('isnull=null'
) and parsed as null values'hidden
: null values are not stringifiedFor more examples, look at the tests.
import { parse, build, omit, keep } from 'search-params'
parse('country=scotland&town=glasgow')
// {
// country: 'scotland',
// town: 'glasgow'
// }
build({
country: 'scotland',
town: 'glasgow'
})
// 'country=scotland&town=glasgow'
omit('country=scotland&town=glasgow', ['country '])
// {
// removedParams: {
// country: 'scotland'
// },
// querystring: 'town=glasgow'
// }
keep('country=scotland&town=glasgow', ['country '])
// {
// keptParams: {
// country: 'scotland'
// },
// querystring: 'country=scotland'
// }
FAQs
A module to manipulate search part of URLs (querystring)
The npm package search-params receives a total of 86,314 weekly downloads. As such, search-params popularity was classified as popular.
We found that search-params demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.