cucumber-expressions
Advanced tools
Comparing version 5.0.5 to 5.0.6
@@ -101,7 +101,8 @@ 'use strict'; | ||
function regexpSource(regexp) { | ||
var flags = regexpFlags(regexp); | ||
var _arr = ['g', 'i', 'm', 'y']; | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
var flag = _arr[_i]; | ||
if (regexp.flags.indexOf(flag) !== -1) throw new CucumberExpressionError('ParameterType Regexps can\'t use flag \'' + flag + '\''); | ||
if (flags.indexOf(flag) !== -1) throw new CucumberExpressionError('ParameterType Regexps can\'t use flag \'' + flag + '\''); | ||
} | ||
@@ -111,2 +112,19 @@ return regexp.source; | ||
// Backport RegExp.flags for Node 4.x | ||
// https://github.com/nodejs/node/issues/8390 | ||
// | ||
// For some strange reason this is not needed for | ||
// `./mocha dist/test`, but it is needed for | ||
// `./mocha dist/test/parameter_type_test.js` | ||
function regexpFlags(regexp) { | ||
var flags = regexp.flags; | ||
if (flags === undefined) { | ||
flags = ''; | ||
if (regexp.ignoreCase) flags += 'i'; | ||
if (regexp.global) flags += 'g'; | ||
if (regexp.multiline) flags += 'm'; | ||
} | ||
return flags; | ||
} | ||
module.exports = ParameterType; |
{ | ||
"name": "cucumber-expressions", | ||
"version": "5.0.5", | ||
"version": "5.0.6", | ||
"description": "Cucumber Expressions - a simpler alternative to Regular Expressions", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -85,4 +85,6 @@ const { CucumberExpressionError } = require('./errors') | ||
function regexpSource(regexp) { | ||
const flags = regexpFlags(regexp) | ||
for (const flag of ['g', 'i', 'm', 'y']) { | ||
if (regexp.flags.indexOf(flag) !== -1) | ||
if (flags.indexOf(flag) !== -1) | ||
throw new CucumberExpressionError( | ||
@@ -95,2 +97,19 @@ `ParameterType Regexps can't use flag '${flag}'` | ||
// Backport RegExp.flags for Node 4.x | ||
// https://github.com/nodejs/node/issues/8390 | ||
// | ||
// For some strange reason this is not needed for | ||
// `./mocha dist/test`, but it is needed for | ||
// `./mocha dist/test/parameter_type_test.js` | ||
function regexpFlags(regexp) { | ||
let flags = regexp.flags | ||
if (flags === undefined) { | ||
flags = '' | ||
if (regexp.ignoreCase) flags += 'i' | ||
if (regexp.global) flags += 'g' | ||
if (regexp.multiline) flags += 'm' | ||
} | ||
return flags | ||
} | ||
module.exports = ParameterType |
@@ -6,3 +6,3 @@ /* eslint-env mocha */ | ||
describe('ParameterType', () => { | ||
it('exposes group source', () => { | ||
it('does not allow ignore flag on regexp', () => { | ||
assertThrows( | ||
@@ -9,0 +9,0 @@ () => |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
202847
2552