File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 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' )
26const debug = require ( './debug' )
37exports = module . exports = { }
48
@@ -19,7 +23,7 @@ const LETTERDASHNUMBER = '[a-zA-Z0-9-]'
1923// all input should have extra whitespace removed.
2024const safeRegexReplacements = [
2125 [ '\\s' , 1 ] ,
22- [ '\\d' , MAX_SAFE_COMPONENT_LENGTH ] ,
26+ [ '\\d' , MAX_LENGTH ] ,
2327 [ LETTERDASHNUMBER , MAX_SAFE_BUILD_LENGTH ] ,
2428]
2529
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const t = require('tap')
22const valid = require ( '../../functions/valid' )
33const SemVer = require ( '../../classes/semver' )
44const invalidVersions = require ( '../fixtures/invalid-versions' )
5+ const { MAX_SAFE_INTEGER } = require ( '../../internal/constants' )
56
67t . test ( 'returns null instead of throwing when presented with garbage' , t => {
78 t . plan ( invalidVersions . length )
@@ -17,3 +18,12 @@ t.test('validate a version into a SemVer object', t => {
1718 t . equal ( valid ( '4.2.0foo' , { loose : true } ) , '4.2.0-foo' , 'looseness as an option' )
1819 t . end ( )
1920} )
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