unjs/ufo

Additional utils: keepQuery and withoutQuery

Opened this issue · 1 comments

Describe the feature

keepQuery(input: string, keep string | string[])
Removes all queries not specified in parameter keep

Example:
keepQuery('/path?foo=a&bar=b', 'bar') // "/path?bar=b"

and

withoutQuery(input: string, without string | string[])
Keeps all queries other than specified in parameter without

Example:
withoutQuery('/path?foo=a&bar=c', 'bar') // "/path?foo=a"

Additional information

  • Would you be willing to help implement this feature?
pi0 commented

Hi thanks for idea. I think we can aggregate both to something like filterQuery(input, fn) wdyt?

But also can you please explain when you think this feature would benefit a share usecase for projects?