sls-helper-plugin-janis
Version:
A Serverless Helper plugin to add custom helpers for Janis Commerce
22 lines (16 loc) • 337 B
JavaScript
;
const pathParameterRegex = /{([a-z0-9_-]+)}/ig;
const getPathParameters = path => {
const matches = path.match(pathParameterRegex);
if(!matches)
return;
return matches.reduce((acum, match) => {
return {
...acum,
[match.replace(/[{}]/g, '')]: true
};
}, {});
};
module.exports = {
getPathParameters
};