sindresorhus/normalize-url

Suggestion: keepQueryParameters

Closed this issue · 0 comments

Hi. I have a new option suggestion.
When we set removeQueryParameters to an array, the package remove query parameters that matches any of the provided strings or regexes. But it would be great if we could reverse this. We will set keepQueryParameters to an array, and the package will only keep that matches any of the provided strings or regexes.

removeQueryParameters:

normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
	removeQueryParameters: ['ref']
});
//=> 'http://sindresorhus.com/?foo=bar'

My suggestion:

normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
	keepQueryParameters: ['ref']
});
//=> 'http://sindresorhus.com/?ref=test_ref'