setup-rust-action/node_modules/@octokit/endpoint/dist-src/util/add-query-parameters.js
Héctor Ramón Jiménez 7f8c3a27a4 Track node_modules
2019-08-15 19:37:37 +02:00

22 lines
622 B
JavaScript

export function addQueryParameters(url, parameters) {
const separator = /\?/.test(url) ? "&" : "?";
const names = Object.keys(parameters);
if (names.length === 0) {
return url;
}
return (url +
separator +
names
.map(name => {
if (name === "q") {
return ("q=" +
parameters
.q.split("+")
.map(encodeURIComponent)
.join("+"));
}
return `${name}=${encodeURIComponent(parameters[name])}`;
})
.join("&"));
}