UNPKG

@scalar/api-client

Version:

the open source API testing client

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