Skip to content

Commit

Permalink
Remove left-over api-utils method (#17595)
Browse files Browse the repository at this point in the history
Noticed this method was left-over from previous query handling logic in `api-utils` while working on #17370 so this removes the extra code which should be safe since `api-utils` is an internal file that shouldn't be relied on externally.
  • Loading branch information
ijjk committed Oct 4, 2020
1 parent f8aeaa4 commit 91b5390
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions packages/next/next-server/server/api-utils.ts
Expand Up @@ -162,34 +162,6 @@ function parseJson(str: string): object {
}
}

/**
* Parsing query arguments from request `url` string
* @param url of request
* @returns Object with key name of query argument and its value
*/
export function getQueryParser({ url }: IncomingMessage) {
return function parseQuery(): NextApiRequestQuery {
const { URL } = require('url')
// we provide a placeholder base url because we only want searchParams
const params = new URL(url, 'https://n').searchParams

const query: { [key: string]: string | string[] } = {}
for (const [key, value] of params) {
if (query[key]) {
if (Array.isArray(query[key])) {
;(query[key] as string[]).push(value)
} else {
query[key] = [query[key], value]
}
} else {
query[key] = value
}
}

return query
}
}

/**
* Parse cookies from `req` header
* @param req request object
Expand Down

0 comments on commit 91b5390

Please sign in to comment.