@apideck/portman
Version:
Port OpenAPI Spec to Postman Collection, with contract & variation tests included
20 lines • 669 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.pathToRegExp = void 0;
var pathToRegExp = function (path) {
var pattern = path
.replace(/{/g, ':')
.replace(/}/g, '')
.replace(/\./g, '\\.')
.replace(/\/\//g, '/')
.replace(/\?/g, '\\?')
.replace(/\/+$/, '')
.replace(/\*+/g, '.*')
.replace(/:([^\d|^\/][a-zA-Z0-9_]*(?=(?:\/|\\.)|$))/g, function (_, paramName) {
return "(?<".concat(paramName, ">[^/]+?)");
})
.concat('(\\/|$)');
return new RegExp(pattern, 'gi');
};
exports.pathToRegExp = pathToRegExp;
//# sourceMappingURL=pathToRegex.js.map