fix regexps with lookahead

This commit is contained in:
Roman Volosovskyi 2017-08-11 23:34:13 +03:00
parent a601a702b2
commit cc066a0a3d
No known key found for this signature in database
GPG Key ID: B24406D8B8CED856
4 changed files with 11 additions and 11 deletions

View File

@ -1141,15 +1141,17 @@
// Handle values that fail the validity test in BigNumber.
parseNumeric = (function () {
var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
var basePrefix = /^((-?)0([xbo]))(\w[\w.]*)$/i,
dotAfter = /^([^.]+)\.$/,
dotBefore = /^\.([^.]+)$/,
isInfinityOrNaN = /^-?(Infinity|NaN)$/,
whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
whitespaceOrPlus = /^\s*\+([\w.])|^\s+|\s+$/g;
return function ( x, str, num, b ) {
var base,
s = num ? str : str.replace( whitespaceOrPlus, '' );
s = num ? str : str.replace(whitespaceOrPlus, function (m, p1) {
return m.indexOf('+') > -1 && p1 !== '' ? p1 : '';
});
// No exception on ±Infinity or NaN.
if ( isInfinityOrNaN.test(s) ) {
@ -1157,10 +1159,10 @@
} else {
if ( !num ) {
// basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
s = s.replace( basePrefix, function ( m, p1, p2 ) {
// basePrefix = /^((-?)0([xbo]))(\w[\w.]*)$/i
s = s.replace( basePrefix, function ( s, m, p1, p2, p3 ) {
base = ( p2 = p2.toLowerCase() ) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
return !b || b == base ? p1 : m;
return (!b || b == base ? p1 : m) + p3;
});
if (b) {

File diff suppressed because one or more lines are too long

4
bignumber.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -31,6 +31,6 @@
"license": "MIT",
"scripts": {
"test": "node ./test/every-test.js",
"build": "uglifyjs bignumber.js --source-map bignumber.js.map -c -m -o bignumber.min.js --preamble \"/* bignumber.js v4.0.2 https://github.com/MikeMcl/bignumber.js/LICENCE */\""
"build": "uglifyjs bignumber.js --source-map -c -m -o bignumber.min.js --preamble \"/* bignumber.js v4.0.2 https://github.com/MikeMcl/bignumber.js/LICENCE */\""
}
}