@@ -7,6 +7,10 @@ const DEFAULTS = {
77 data : false
88} ;
99
10+ function getVersionString ( item ) {
11+ return typeof item === 'string' ? item : item . version ;
12+ }
13+
1014/**
1115 * Sorts version strings in descending order and returns the highest version
1216 * @param {string[] } versions - Array of version strings (e.g., ['1.11.2', '1.11.1'])
@@ -30,13 +34,15 @@ function validateVersion(version) {
3034
3135 const ver = String ( version ) . trim ( ) ;
3236
33- if ( p5Versions . includes ( ver ) ) return ver ;
37+ const versions = p5Versions . map ( getVersionString ) ;
38+
39+ if ( versions . includes ( ver ) ) return ver ;
3440
3541 // if only major.minor provided like "1.11"
3642 const majorMinorMatch = / ^ ( \d + ) \. ( \d + ) $ / . exec ( ver ) ;
3743 if ( majorMinorMatch ) {
3844 const [ , major , minor ] = majorMinorMatch ;
39- const matches = p5Versions . filter ( ( v ) => {
45+ const matches = versions . filter ( ( v ) => {
4046 const parts = v . split ( '.' ) ;
4147 return parts [ 0 ] === major && parts [ 1 ] === minor ;
4248 } ) ;
@@ -49,7 +55,7 @@ function validateVersion(version) {
4955 const majorOnlyMatch = / ^ ( \d + ) $ / . exec ( ver ) ;
5056 if ( majorOnlyMatch ) {
5157 const [ , major ] = majorOnlyMatch ;
52- const matches = p5Versions . filter ( ( v ) => v . split ( '.' ) [ 0 ] === major ) ;
58+ const matches = versions . filter ( ( v ) => v . split ( '.' ) [ 0 ] === major ) ;
5359 if ( matches . length ) {
5460 return getNewestVersion ( matches ) ;
5561 }
0 commit comments