Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
query-string-manipulator
Advanced tools
Readme
Effortlessly manipulate query string parameters into your desired URL. You pass url and a set of actions to be done to QSM and you get you URL string back.
QSM is written for ES modules
npm install query-string-manipulator
Lets assume that you already have it imported
import qsm from 'query-string-manipulator';
Lets say that you want to add page number to a search result.
qsm('https://www.google.cz/search?q=hello+world', {
set: {
num: 20,
}
});
// https://www.google.cz/search?q=hello+world&num=20
It also works if the page number is already set
qsm('https://www.google.cz/search?q=hello+world&num=20', {
set: {
num: 40,
}
});
// https://www.google.cz/search?q=hello+world&num=40
It also works when passing a parameter as an array.
qsm('https://www.google.cz/search?q=hello+world&num=20', {
set: {
num: [20, 40, 60],
}
});
// https://www.google.cz/search?q=hello+world&num=20&num=40&num=60
Say that you now want to go back to first page
qsm('https://www.google.cz/search?q=hello+world&num=20', {
remove: ['num']
});
// https://www.google.cz/search?q=hello+world
Or go to the empty search page
qsm('https://www.google.cz/search?q=hello+world&num=20', {
remove: ['q', 'num']
});
// https://www.google.cz/search
Say that you have a button on your page that enables filter and disables it when you click it again.
qsm('https://www.google.cz/search?q=hello+world&num=20', {
toggle: {
tbm: 'isch',
}
});
// https://www.google.cz/search?q=hello+world&num=20&tbm=isch
qsm('https://www.google.cz/search?q=hello+world&num=20&tbm=isch', {
toggle: {
tbm: 'isch',
}
});
// https://www.google.cz/search?q=hello+world&num=20
If you like "symbols", you can go like this:
import qsm, {
URL_REMOVE, // Used for remove
URL_SET, // Used for set
URL_TOGGLE, // Used for toggle
} from 'query-string-manipulator';
qsm('http://example.com/', {
[URL_REMOVE]: ['test'],
[URL_TOGGLE]: {
foo: 'bar',
},
[URL_SET]: {
xxx: '123',
},
})
But wait, there is more!
Method getUrlParams
returns list of all parameters in form of array of objects. It cannot be returned in form of key-pair values because there can be multiple same name query params.
getUrlParams('https://example.com/foo?select=users&getId=10')
/* returns
[
{
key: 'select',
value: 'users'
},
{
key: 'getId',
value: '10',
}
]
*/
Method resolveUrlParams
returns parameters after changed by user specified actions.
const urlParams = [
{
key: 'select',
value: 'users'
},
{
key: 'getId',
value: '10'
}
];
const paramActions = {
remove: ['getId'],
set: {
select: 'userGroups',
},
};
resolveUrlParams(urlParams, paramActions)
/* returns
[
{
key: 'select',
value: 'userGroups'
}
]
*/
Method constructUrlParams
returns query string part of the URL from parameters.
constructUrlParams([
{
key: 'select',
value: 'users'
},
{
key: 'getId',
value: '10'
}
])
// returns "select=users&getId=10"
FAQs
Manipulate query strings without effort
The npm package query-string-manipulator receives a total of 150 weekly downloads. As such, query-string-manipulator popularity was classified as not popular.
We found that query-string-manipulator 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.