roc
Version:
Build modern web applications easily
27 lines (22 loc) • 631 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = toRegExp;
var _lodash = require('lodash');
/**
* Given an input the function will return a RegExp.
*
* @param {object} input - The input to be converted.
*
* @returns {RegExp} - The converted result.
*/
function toRegExp(input) {
if ((0, _lodash.isRegExp)(input)) {
return input;
}
// Remove potential leading / / and get possible flags
const parsedInput = /^\/?(.*?)(?:\/?|\/([gimuy]*))$/.exec(input);
return new RegExp(parsedInput[1], parsedInput[2]);
}
//# sourceMappingURL=to-regexp.js.map