Skip to content

Provide an option to ignore empty/falsy objects/arrays/values in encodeQString #2

@bengillies

Description

@bengillies

Currently, encoding empty/falsy objects/values as a query string results in params that represent empty versions of that data type. For example:

> juri.encodeQString({
  foo: {},
  bar: [],
  baz: '',
  qux: false
});

'foo=(:)&bar=()&baz=\'\'&qux=--'

I can can see how this might be useful in some cases, but in other cases, it's both shorter and more reasonable to just ignore them completely. Ideally, something along the following lines would be great:

> juri.encodeQString({
  foo: {},
  bar: [],
  baz: '',
  qux: false
}, { stripEmpty: true });

''

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