MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / convertQueryParamsToSnake

Function convertQueryParamsToSnake

frontend/packages/common/src/hooks/http.ts:53–71  ·  view source on GitHub ↗
(
  params: { [k: string]: unknown },
  shouldTransformKeys: boolean,
  transformKeys: string[]
)

Source from the content-addressed store, hash-verified

51
52// 将查询字符串的键从驼峰转换为下划线
53function convertQueryParamsToSnake(
54 params: { [k: string]: unknown },
55 shouldTransformKeys: boolean,
56 transformKeys: string[]
57) {
58 const newParams = new URLSearchParams()
59
60 for (const key in params) {
61 if (shouldTransformKeys && transformKeys?.includes(key)) {
62 const newKey = toSnake(key)
63 const value = params[key]
64 appendParam(newParams, newKey, value as Array<string> | string)
65 } else {
66 appendParam(newParams, key, params[key] as Array<string> | string)
67 }
68 }
69
70 return newParams
71}
72
73function appendParam(params: URLSearchParams, key: string, value: Array<string> | string) {
74 if (value !== undefined && value !== null) {

Callers 1

processQueryParamsFunction · 0.85

Calls 2

toSnakeFunction · 0.85
appendParamFunction · 0.85

Tested by

no test coverage detected