RVC_RULE1 / node_modules /@octokit /endpoint /dist-src /util /extract-url-variable-names.js
David Thomas
updated UI
77731d1
raw
history blame contribute delete
377 Bytes
const urlVariableRegex = /\{[^}]+\}/g;
function removeNonChars(variableName) {
return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
}
function extractUrlVariableNames(url) {
const matches = url.match(urlVariableRegex);
if (!matches) {
return [];
}
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
}
export {
extractUrlVariableNames
};