jest-ex
Version:
A runner and a transformer to simplify (a little bit) your work with Jest.
24 lines (21 loc) • 552 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* Escape a string you want to use on a regular expression so it won't contain invalid
* characters/symbols.
*
* @example
* console.log(escapeRegex('./some-path/'));
* // It would output '\\./some\\-path/'
*
* @param {String} str The string to escape
* @return {String} The escaped string.
*/
const escapeRegex = str => str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
var _default = {
escapeRegex
};
exports.default = _default;