UNPKG

@scalar/api-client

Version:

the open source API testing client

33 lines (32 loc) 857 B
import { replaceTemplateVariables as s } from "../string-template.js"; function f(l, o, n) { const r = new URLSearchParams(), i = ((n == null ? void 0 : n.parameters) ?? []).reduce( (e, a) => (a.in === "query" && (e[a.name] = a), e), {} ); return l.parameters.query.forEach((e) => { if (!e.enabled) return; const a = i[e.key]; switch (e.type) { case "array": { const t = s(e.value ?? "", o).split(/,\ ?/); if ((a == null ? void 0 : a.explode) === !1) { const c = t.join(","); r.append(e.key, c); } else t.forEach((c) => { r.append(e.key, c.trim()); }); break; } default: { const t = s(e.value ?? "", o); r.append(e.key, t.trim()); break; } } }), r; } export { f as createFetchQueryParams };