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

12 lines
360 B
JavaScript

const urlVariableRegex = /\{[^}]+\}/g;
function removeNonChars(variableName) {
return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
}
export function extractUrlVariableNames(url) {
const matches = url.match(urlVariableRegex);
if (!matches) {
return [];
}
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
}