Skip to content

Commit

Permalink
Always apply aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixinova committed Jun 5, 2024
1 parent 67da4d6 commit 81ebfa3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
16 changes: 10 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/pack-formats-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 81ebfa3

Please sign in to comment.