diff --git a/changelog.md b/changelog.md index 0544672..cda8afc 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## Next - Updated resource pack format to `34`. - Updated data pack format to `48`. +- Fixed special case checking not being applied to full version names leading to no result for certain versions. ## 1.3.15 *2024-05-12* diff --git a/src/index.ts b/src/index.ts index c593ef0..7889775 100644 --- a/src/index.ts +++ b/src/index.ts @@ -106,7 +106,16 @@ const LATEST = { resource: maxFormat('resource'), data: maxFormat('data') }; */ function getPackFormat(version: string, type: PackType = 'resource'): FormatResult { if (!version) return undefined - version = version.toString().toLowerCase().trim() + + // Prepare version string for comparison + version = version + .toString() + .trim() + .toLowerCase() + // Aliasing + .replace(/-? *pre[- ]?(release)? */, '-pre') + .replace(/ *release candidate */, '-rc') + .replace(/ *experimental *snapshot|-es/, '-exp') // Special // for (const format in SPECIAL[type]) { @@ -126,11 +135,6 @@ function getPackFormat(version: string, type: PackType = 'resource'): FormatResu // Release // - version = version - .replace(/-? *pre[- ]?(release)? */, '-pre') - .replace(/ *release candidate */, '-rc') - .replace(/ *experimental *snapshot|-es/, '-exp') - if (version.includes('-')) { // Special cases for specific development versions if (version.includes('1.16.2-pre')) return 5 diff --git a/test/pack-formats-tests.txt b/test/pack-formats-tests.txt index 52cd0d9..4d1e264 100644 --- a/test/pack-formats-tests.txt +++ b/test/pack-formats-tests.txt @@ -71,6 +71,7 @@ Types: "1.20.5-rc1" (r) 32 "1.20.5-rc1" (d) 41 "1.21-pre1" (r) 34 +"1.21 pre-release 1" (r) 34 "1.21-pre1" (d) 46 "1.21-pre2" (d) 47 "1.21-pre3" (d) 48