Innovenergy_trunk/frontend/node_modules/testcafe/lib/utils/make-reg-exp.js

22 lines
2.6 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeRegExp = exports.parseRegExpString = void 0;
const escapeRegExp_1 = __importDefault(require("lodash/escapeRegExp"));
const SPLIT_INPUT_AND_FLAGS_REG_EXP = /^\/(.*?)\/([gim]*)$/;
function parseRegExpString(regExp) {
if (typeof regExp !== 'string')
return regExp;
const parsedRegExpWithFlags = regExp.match(SPLIT_INPUT_AND_FLAGS_REG_EXP);
if (parsedRegExpWithFlags)
return RegExp(parsedRegExpWithFlags[1], parsedRegExpWithFlags[2]);
return makeRegExp(regExp);
}
exports.parseRegExpString = parseRegExpString;
function makeRegExp(str, flags) {
return typeof str === 'string' ? new RegExp((0, escapeRegExp_1.default)(str), flags) : str;
}
exports.makeRegExp = makeRegExp;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFrZS1yZWctZXhwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL21ha2UtcmVnLWV4cC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSx1RUFBK0M7QUFFL0MsTUFBTSw2QkFBNkIsR0FBRyxxQkFBcUIsQ0FBQztBQUU1RCxTQUFnQixpQkFBaUIsQ0FBRSxNQUFNO0lBQ3JDLElBQUksT0FBTyxNQUFNLEtBQUssUUFBUTtRQUMxQixPQUFPLE1BQU0sQ0FBQztJQUVsQixNQUFNLHFCQUFxQixHQUFHLE1BQU0sQ0FBQyxLQUFLLENBQUMsNkJBQTZCLENBQUMsQ0FBQztJQUUxRSxJQUFJLHFCQUFxQjtRQUNyQixPQUFPLE1BQU0sQ0FBQyxxQkFBcUIsQ0FBQyxDQUFDLENBQUMsRUFBRSxxQ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