ljharb/qs

Add the ability to enable strict RFC 3986 conformance for decoding as well as encoding

Open

#205 ouverte le 10 avr. 2017

Voir sur GitHub
 (1 commentaire) (5 réactions) (0 assignés)JavaScript (744 forks)batch import
enhancementhelp wantedparsesemver-minor: new features

Métriques du dépôt

Stars
 (8 015 stars)
Métriques de merge PR
 (Merge moyen 6j 22h) (2 PRs mergées en 30 j)

Description

To achieve strict RFC 3986 conformance (specifically, '+' in query strings is a LITERAL '+' and not a placeholder for ' ' as per the W3C's URL recommendations, the following is necessary:

qs.parse(s, {
    decoder: (str) => {
        try {
            return decodeURIComponent(str);
        } catch (e) {
            return str;
        }
    },
})

For those of us who prefer strict RFC 3986 conformance, I suggest an option like:

qs.parse(s, {
    format: 'RFC3986',
})

which would be much more concise and not require knowing the implementation details of the default decode function.

Guide contributeur