setup-maven/node_modules/@octokit/endpoint/dist-src/util/extract-url-variable-names.js

12 lines
360 B
JavaScript
Raw Normal View History

2019-12-07 13:09:20 +00:00
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), []);
}