source: trip-planner-front/node_modules/adjust-sourcemap-loader/lib/process/to-reg-exp.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 701 bytes
RevLine 
[6a3a178]1'use strict';
2
3var regexParser = require('regex-parser');
4
5var REGEXP = /(\/?)(.+)\1([a-z]*)/i;
6
7/**
8 * Parse the give value as a regular expression or give a pass-none expression where it is invalid
9 * @param {RegExp|string|*} value An existing expression, or its string representation, or degenerate value
10 * @returns {RegExp} The given expression or one matching the RegExp string else a pass-none expression
11 */
12function toRegExp(value) {
13 return ((typeof value === 'object') && (typeof value.test === 'function') && value) ||
14 ((typeof value === 'string') && REGEXP.test(value) && regexParser(value)) ||
15 (/^true$|^$/.test(value) && /.*/) ||
16 /matchnone^/;
17}
18
19module.exports = toRegExp;
Note: See TracBrowser for help on using the repository browser.