1
0
Fork 0
mirror of https://github.com/actions/setup-node synced 2024-12-25 06:32:41 +00:00
setup-node/node_modules/@octokit/endpoint/dist-src/util/extract-url-variable-names.js
Danny McCormick 5273d0df9c Add auth
2019-08-06 18:29:44 -04:00

11 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), []);
}