MCPcopy
hub / github.com/ThatGuySam/doesitarm / normalizeVersion

Function normalizeVersion

build-lists.js:73–96  ·  view source on GitHub ↗
( rawVersion )

Source from the content-addressed store, hash-verified

71
72
73function normalizeVersion ( rawVersion ) {
74 const containsNumbers = /\d+/.test( rawVersion )
75
76 if ( !containsNumbers ) {
77 return '0.0.0'
78 }
79
80 let version = rawVersion
81
82 // Parse each part
83 version = version
84 .split('.')
85 .map( part => {
86 // It it's just a single digit
87 // pass it as-is
88 if ( part.length === 1 ) return part
89
90 // Trim leading zeros
91 return part.replace(/^0+/, '')
92 } )
93 .join('.')
94
95 return semver.coerce(version)
96}
97
98
99

Callers 1

sortBundleVersionsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected