stephenlacy / bump-regex

bump regex with semver
MIT License
13 stars 10 forks source link

Fails when key contains a - (dash) #11

Closed chatu closed 7 years ago

chatu commented 7 years ago

I ran into an interesting bug when trying to bump a version using a key that contains one or mode - (dashes).

Code

var bump = require('bump-regex');

const name = 'latest-release';

bump({ key: 'latest-release', str: 'latest-release:1.6.0' }, function(err, out) {
  console.log(err, out);
});

Output

var regex = opts.regex || new RegExp(
                            ^

SyntaxError: Invalid regular expression: /([<|'|"]?latest-release[>|'|"]?[ ]*[:=]?[ ]*['|"]?[a-z]?)(\d+\.\d+\.\d+)(-[0-9A-Za-z.-]+)?(['|"|<latest-release>]?)/: Range out of order in character class

It treats the -(dash) within the last key as a range (['|"|<latest-release>]?), and t-r is not a valid range.

The sample code stopped working when versioning xml content was added in v2.6.0