Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

UrlSearchParams toString() should not add queryParams if they have no value set #385

Open
krezovic opened this issue Mar 12, 2018 · 0 comments

Comments

@krezovic
Copy link

Enhancement

Package Version: Beta 5

Say that I have search view that has different fields and all are optional. Due to usage of typescript, I need to provide an interface which contains all the fields, but not all fields need to be set (they're undefined if they're not set).

Current implementation of UrlSearchParams appends keys without any value, which is undesired behaviour.

Say that I have (pseudo code, not actually tested, and I can't provide actual code)

interface Foo {
bar: string;
baz: string;
}

const foo: Partial = { bar: 'baz' };

const params = new UrlSearchParams(foo);

params.toString() =>

baz&bar=baz

I believe the "baz" should not be shown at all in the resulting string.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant