File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
- const { MAX_SAFE_COMPONENT_LENGTH , MAX_SAFE_BUILD_LENGTH } = require ( './constants' )
1
+ const {
2
+ MAX_SAFE_COMPONENT_LENGTH ,
3
+ MAX_SAFE_BUILD_LENGTH ,
4
+ MAX_LENGTH ,
5
+ } = require ( './constants' )
2
6
const debug = require ( './debug' )
3
7
exports = module . exports = { }
4
8
@@ -19,7 +23,7 @@ const LETTERDASHNUMBER = '[a-zA-Z0-9-]'
19
23
// all input should have extra whitespace removed.
20
24
const safeRegexReplacements = [
21
25
[ '\\s' , 1 ] ,
22
- [ '\\d' , MAX_SAFE_COMPONENT_LENGTH ] ,
26
+ [ '\\d' , MAX_LENGTH ] ,
23
27
[ LETTERDASHNUMBER , MAX_SAFE_BUILD_LENGTH ] ,
24
28
]
25
29
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const t = require('tap')
2
2
const valid = require ( '../../functions/valid' )
3
3
const SemVer = require ( '../../classes/semver' )
4
4
const invalidVersions = require ( '../fixtures/invalid-versions' )
5
+ const { MAX_SAFE_INTEGER } = require ( '../../internal/constants' )
5
6
6
7
t . test ( 'returns null instead of throwing when presented with garbage' , t => {
7
8
t . plan ( invalidVersions . length )
@@ -17,3 +18,12 @@ t.test('validate a version into a SemVer object', t => {
17
18
t . equal ( valid ( '4.2.0foo' , { loose : true } ) , '4.2.0-foo' , 'looseness as an option' )
18
19
t . end ( )
19
20
} )
21
+
22
+ t . test ( 'long build id' , t => {
23
+ const longBuild = '-928490632884417731e7af463c92b034d6a78268fc993bcb88a57944'
24
+ const shortVersion = '1.1.1'
25
+ const longVersion = `${ MAX_SAFE_INTEGER } .${ MAX_SAFE_INTEGER } .${ MAX_SAFE_INTEGER } `
26
+ t . equal ( valid ( shortVersion + longBuild ) , shortVersion + longBuild )
27
+ t . equal ( valid ( longVersion + longBuild ) , longVersion + longBuild )
28
+ t . end ( )
29
+ } )
You can’t perform that action at this time.
0 commit comments