@lodestar/api
Version:
A Typescript REST client for the Ethereum Consensus API
19 lines • 565 B
JavaScript
import { stringify as queryStringStringify } from "qs";
/**
* Ethereum Beacon API requires the query with format:
* - arrayFormat: repeat `topic=topic1&topic=topic2`
*/
export function stringifyQuery(query) {
return queryStringStringify(query, { arrayFormat: "repeat" });
}
/**
* TODO: Optimize, two regex is a bit wasteful
*/
export function urlJoin(...args) {
return (args
.join("/")
.replace(/([^:]\/)\/+/g, "$1")
// Remove duplicate slashes in the front
.replace(/^(\/)+/, "/"));
}
//# sourceMappingURL=format.js.map