Skip to content
This repository was archived by the owner on Jul 30, 2018. It is now read-only.
This repository was 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

Description

@krezovic

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions