fix(core): request url parse error
MODIFY
packages/@integration/test/integration.spec.ts
packages/@integration/test/integration.spec.ts
@@ -71,6 +71,15 @@ describe('API integration', () => {
expect(body).toHaveLength(3);
}));
+ test(`GET returns 200 with Content-Type=application/json: /api/v1/user?email=test%40test.com`, async () =>
+ request(server)
+ .get('/api/v1/user?email=test%40test.com')
+ .set('Authorization', 'Bearer FAKE')
+ .expect(200)
+ .then(({ header }) => {
+ expect(header['content-type']).toBe(ContentType.APPLICATION_JSON);
+ }));
+
test('GET returns single object: /api/v1/user/10', async () =>
request(server)
.get('/api/v1/user/10')

MODIFY
packages/core/src/response/response.handler.ts
packages/core/src/response/response.handler.ts
+import * as url from 'url';
import { EMPTY } from 'rxjs';
import { HttpEffectResponse } from '../effects/http-effects.interface';
import { HttpRequest, HttpResponse, HttpStatus } from '../http.interface';
@@ -10,8 +11,9 @@ export const handleResponse = (res: HttpResponse) => (req: HttpRequest) => (effe
if (res.finished) { return EMPTY; }
const status = effect.status || HttpStatus.OK;
+ const path = url.parse(req.url).pathname || '';
- const headersFactoryWithData = headersFactory({ body: effect.body, path: req.url, status });
+ const headersFactoryWithData = headersFactory({ body: effect.body, path, status });
const headers = headersFactoryWithData(effect.headers);
const bodyFactoryWithHeaders = bodyFactory(headers);

MODIFY
packages/core/src/router/specs/router.query.factory.spec.ts
packages/core/src/router/specs/router.query.factory.spec.ts
@@ -61,4 +61,16 @@ describe('#queryParamsFactory', () => {
// then
expect(params).toEqual(expectedParamsObj);
});
+
+ test('parses URL like parameter', () => {
+ // given
+ const exampleURL = 'user=test%40test.com';
+ const expectedParamsObj = { user: 'test@test.com' };
+
+ // when
+ const params = queryParamsFactory(exampleURL);
+
+ // then
+ expect(params).toEqual(expectedParamsObj);
+ })
});

fix(core): request url parse error