Closed ultralabsgev closed 3 years ago
I'm not sure what you're asking - you need the colons unencoded? Why?
Can you provide search
so i can try to reproduce this?
openingStatuses=Submitted&dateStart=2021-08-02T20%3A00%3A00.000Z&dateEnd=2021-08-19T20%3A00%3A00.000Z
%3A = :
> qs.parse('openingStatuses=Submitted&dateStart=2021-08-02T20%3A00%3A00.000Z&dateEnd=2021-08-19T20%3A00%3A00.000Z', { charset: 'utf-8' })
{
openingStatuses: 'Submitted',
dateStart: '2021-08-02T20:00:00.000Z',
dateEnd: '2021-08-19T20:00:00.000Z'
}
> qs.parse('openingStatuses=Submitted&dateStart=2021-08-02T20%3A00%3A00.000Z&dateEnd=2021-08-19T20%3A00%3A00.000Z', {
charset: 'utf-8',
decoder(str, defaultDecoder, charset, type) {
var result = defaultDecoder(str); return type === 'key' ? result : [result];
}
});
{
openingStatuses: [ 'Submitted' ],
dateStart: [ '2021-08-02T20:00:00.000Z' ],
dateEnd: [ '2021-08-19T20:00:00.000Z' ]
}
f*** I forgot about the default decoder thx
when I'm parsing my URL decoder ignoring charset. os I decoding charsets manually
qs.parse(search, { charset: 'utf-8', ignoreQueryPrefix: true, decoder: customDecoder, })
const customDecoder = ( str: string, defaultDecoder: (str: string, decoder?: any, charset?: string) => string, charset: string, type: 'key' | 'value' ) => { if (type === 'key') { return str; } return [str]; };
this is my problem what I need
dateEnd: ["2021-08-18T20:00:00.000Z"] dateStart: ["2021-08-02T20:00:00.000Z"]
this is what I get with my decoder
dateEnd: ["2021-08-18T20%3A00%3A00.000Z"] dateStart: ["2021-08-02T20%3A00%3A00.000Z"]
this is my fix but it's BS I add it inside my decoder
const validStr = str.replace(/%20/g, ' ').replace(/%3A/g, ':');