diff --git a/package.json b/package.json index 015ccf46638e..90a1eb24c0f5 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "@commitlint/config-angular": "^4.3.0", "@commitlint/config-lerna-scopes": "^4.3.0", "@types/mocha": "^2.2.44", - "@types/node": "^8.0.50", + "@types/node": "^8.0.56", "@types/request": "^2.0.7", "@types/request-promise": "^4.1.39", "coveralls": "^3.0.0", diff --git a/packages/rest/src/internal-types.ts b/packages/rest/src/internal-types.ts index 9ddd8a698cf1..74e9694e9c36 100644 --- a/packages/rest/src/internal-types.ts +++ b/packages/rest/src/internal-types.ts @@ -11,7 +11,7 @@ export interface ParsedRequest extends ServerRequest { // see http://expressjs.com/en/4x/api.html#req.path path: string; // see http://expressjs.com/en/4x/api.html#req.query - query: {[key: string]: string}; + query: {[key: string]: string | string[]}; // see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/15808 url: string; pathname: string; diff --git a/packages/rest/src/router/routing-table.ts b/packages/rest/src/router/routing-table.ts index b70bc7d5c93d..846495e27b6c 100644 --- a/packages/rest/src/router/routing-table.ts +++ b/packages/rest/src/router/routing-table.ts @@ -45,7 +45,13 @@ export function parseRequestUrl(request: ServerRequest): ParsedRequest { const parsedRequest = request as ParsedRequest; const parsedUrl = url.parse(parsedRequest.url, true); parsedRequest.path = parsedUrl.pathname || '/'; - parsedRequest.query = parsedUrl.query; + // parsedUrl.query cannot be a string as it is parsed with + // parseQueryString = true + if (parsedUrl.query != null && typeof parsedUrl.query !== 'string') { + parsedRequest.query = parsedUrl.query; + } else { + parsedRequest.query = {}; + } return parsedRequest; }