未验证 提交 91b53906 编写于 作者: J JJ Kasper 提交者: GitHub

Remove left-over api-utils method (#17595)

Noticed this method was left-over from previous query handling logic in `api-utils` while working on https://github.com/vercel/next.js/pull/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. 
上级 f8aeaa47
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册