Danny McCormick 5273d0df9c
Some checks failed
Main workflow / Run (ubuntu-latest) (push) Has been cancelled
Main workflow / Run (windows-latest) (push) Has been cancelled
Add auth
2019-08-06 18:29:44 -04: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), []);
}