Skip to content

Issue for ISO 8601 dates on arrayFormat separator option #242

Closed
@jessedobbelaere

Description

@jessedobbelaere

On v6.10.1 we were succesfully parsing the following two url params using the comma parser:

parse(queryString, { arrayFormat: "comma", parseBooleans: true, parseNumbers: true });
// Request: id%28in%29=992232%2C992237%2C992240
// Parsed: 
// {
//    id(in): [992232, 992237, 992240],
// }

// Request: timestamp_begin(gte)=2020-01-01T00:00:00%2B03:00
// Parsed: 
// {
//     timestamp_begin(gte): "2020-01-01T00:00:00+03:00"
// }

Here, our ISO 8601 datetime is not getting modified ✅ .

However, with the release of v6.11.0, we ran into issues because of the encoded commas that are passed to our API, due to the change of (#236).
After switching to the arrayFormat "separator" we seem to get the old behaviour from v6.10.1 with our encoded comma arrays, except for one issue with our ISO 8601 DateTime.

parse(queryString, { arrayFormat: "separator", parseBooleans: true, parseNumbers: true });
// Request: id%28in%29=992232%2C992237%2C992240
// Parsed: 
// {
//    id(in): [992232, 992237, 992240],
// }
// This works great again

// Request: timestamp_begin(gte)=2020-01-01T00:00:00%2B03:00
// Parsed: 
// {
//     timestamp_begin(gte): "2020-01-01T00:00:00 03:00"
// }
// Here the + sign is removed from our datetime string

Note: when switching it to arrayFormat: "comma" again the datetime is correct (+ sign not removed. (But we cannot use the comma format because of our encoded comma's in the requests we get.)

Made a small code sample to illustrate: https://stackblitz.com/edit/typescript-udk9sb (open console)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions