Skip to content

Commit fead5dc

Browse files
fix: Al 2800 autosave version error the specified (#10)
* Added charset as 'utf-8'. * Added custom decoder.
1 parent 68f3709 commit fead5dc

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/request.spec.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ describe('Request object version 1.0', () => {
2727
'd[1]': '1',
2828
'd[0]': '0',
2929
'shoe[color]': 'yellow',
30-
email: 'test%2Buser%40gmail.com',
31-
math: '1%2B2'
30+
email: 'test+user@gmail.com',
31+
math: '1+2'
3232
},
3333
multiValueQueryStringParameters: {
3434
a: ['1'],
@@ -37,8 +37,8 @@ describe('Request object version 1.0', () => {
3737
'd[1]': ['1'],
3838
'd[0]': ['0'],
3939
'shoe[color]': ['yellow'],
40-
email: ['test%2Buser%40gmail.com'],
41-
math: ['1%2B2', '4%2B5']
40+
email: ['test+user@gmail.com'],
41+
math: ['1+2', '4+5']
4242
},
4343
stageVariables: {},
4444
requestContext: {},
@@ -200,7 +200,8 @@ describe('Request object version 2.0', () => {
200200
routeKey: '$default',
201201
rawPath: '/my/path',
202202
rawQueryString:
203-
'a=1&b=1&b=2&c[]=-firstName&c[]=lastName&d[1]=1&d[0]=0&shoe[color]=yellow&email=test%2Buser%40gmail.com&math=1%2B2&&math=4%2B5&',
203+
'a=1&b=1&b=2&c[]=-firstName&c[]=lastName&d[1]=1&d[0]=0&shoe[color]=yellow&[email protected]&math=1+2&&math=4+5&',
204+
204205
cookies: ['cookie1', 'cookie2'],
205206
headers: {
206207
'Content-Type': 'application/json',
@@ -214,8 +215,8 @@ describe('Request object version 2.0', () => {
214215
'd[1]': '1',
215216
'd[0]': '0',
216217
'shoe[color]': 'yellow',
217-
email: 'test%2Buser%40gmail.com',
218-
math: '1%2B2'
218+
email: 'test+user@gmail.com',
219+
math: '1+2'
219220
},
220221
requestContext: {
221222
accountId: '123456789012',

src/request.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ export class Request extends Readable {
7575
}
7676

7777
this.query = parse(queryParamsToStringify(event.multiValueQueryStringParameters), {
78-
charset: 'utf-8'
78+
charset: 'utf-8',
79+
decoder: function (str) {
80+
return str
81+
}
7982
}) as {
8083
[name: string]: string | string[]
8184
}
@@ -292,7 +295,10 @@ export class RequestV2 extends Readable {
292295
this.method = event.requestContext.http.method
293296

294297
this.query = parse(event.rawQueryString, {
295-
charset: 'utf-8'
298+
charset: 'utf-8',
299+
decoder: function (str) {
300+
return str
301+
}
296302
}) as { [name: string]: string }
297303

298304
this.path = event.rawPath || ''

0 commit comments

Comments
 (0)