Skip to content

Commit

Permalink
add 32767 to const and tweak failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Jan 12, 2023
1 parent 39f1c2d commit 3dcf6d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/helpers/string-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,10 @@ export function inferValue(value) {

// Number class constructor works 2 times faster than JSON.parse
// and wont interpret mixed inputs like '123asd' as parseFloat would
const MAX_ALLOWED_NUM = 32767;
const numVal = Number(value);
if (!nativeIsNaN(numVal)) {
if (Math.abs(numVal) > 32767) {
if (Math.abs(numVal) > MAX_ALLOWED_NUM) {
throw new Error('number values bigger than 32767 are not allowed');
}
return numVal;
Expand Down
2 changes: 1 addition & 1 deletion tests/scriptlets/trusted-set-cookie.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test('Set cookie with current time value', (assert) => {

// Some time will pass between calling scriptlet
// and qunit running assertion
const tolerance = 100;
const tolerance = 125;
const cookieValue = parseCookieString(document.cookie)[cName];
const currentTime = new Date().getTime();
const timeDiff = currentTime - cookieValue;
Expand Down

0 comments on commit 3dcf6d4

Please sign in to comment.