File tree Expand file tree Collapse file tree 1 file changed +20
-8
lines changed
Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -52,12 +52,24 @@ export const getProjectRepository = (project: string, version: string): string =
5252 if ( project !== "paper" ) return `https://github.com/PaperMC/${ project } ` ;
5353 if ( project === "paper" && version === "1.7.10" ) return "https://github.com/PaperMC/Paper-1.7" ;
5454
55- const baseVersion = [ 21 , 4 ] ; // 1.21.4 is after the hardfork
56- const isBelowBaseVersion = version
57- . replace ( / ^ 1 \. / , "" )
58- . split ( "." )
59- . map ( Number )
60- . some ( ( v , i ) => v < ( baseVersion [ i ] || 0 ) ) ;
61-
62- return isBelowBaseVersion ? "https://github.com/PaperMC/Paper-Archive" : "https://github.com/PaperMC/Paper" ;
55+ const baseVersion = "1.21.4" ; // after the hardfork
56+
57+ return isVersionBelow ( version , baseVersion ) ? "https://github.com/PaperMC/Paper-Archive" : "https://github.com/PaperMC/Paper" ;
6358} ;
59+
60+ function isVersionBelow ( version : string , base : string ) : boolean {
61+ const v = version . split ( "." ) . map ( Number ) ;
62+ const b = base . split ( "." ) . map ( Number ) ;
63+
64+ const len = Math . max ( v . length , b . length ) ;
65+
66+ for ( let i = 0 ; i < len ; i ++ ) {
67+ const vi = v [ i ] ?? 0 ;
68+ const bi = b [ i ] ?? 0 ;
69+
70+ if ( vi < bi ) return true ;
71+ if ( vi > bi ) return false ;
72+ }
73+
74+ return false ;
75+ }
You can’t perform that action at this time.
0 commit comments