Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/license.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ braces
MIT
The MIT License (MIT)

Copyright (c) 2014-2018, Jon Schlinkert.
Copyright (c) 2014-present, Jon Schlinkert.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 4 additions & 1 deletion src/platforms/curseforge/curseforge-game-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function findCurseForgeGameVersionIdsByNames(versions: CurseForgeGameVers

return $i(names)
.map(name => {
const version = versions.find(v => comparer(v.name, name));
const version = versions.find(v => comparer(v.name, name) || comparer(v.slug, name));
if (version || !fallbackComparer) {
return version;
}
Expand Down Expand Up @@ -96,5 +96,8 @@ export function formatCurseForgeGameVersion(gameVersion: GameVersion): string {
* @returns A formatted string representing the game version.
*/
export function formatCurseForgeGameVersionSnapshot(gameVersion: GameVersion): string {
if (gameVersion.isBeta) {
return `Beta ${gameVersion.id.substring(1)}`;
}
return `${gameVersion.version.major}.${gameVersion.version.minor}${gameVersion.version.patch ? `.${gameVersion.version.patch}` : ""}${gameVersion.isSnapshot ? "-Snapshot" : ""}`;
}
37 changes: 33 additions & 4 deletions tests/unit/platforms/curseforge/curseforge-game-version.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ describe("CURSEFORGE_GAME_VERSION_PLUGIN_NAME_COMPARER", () => {

describe("findCurseForgeGameVersionIdsByNames", () => {
const versions = Object.freeze([
{ id: 1, name: "1.17" },
{ id: 2, name: "1.17.1" },
{ id: 3, name: "1.18-Snapshot" },
{ id: 4, name: "CB 1.4.6-R0.1" },
{ id: 1, slug: "1-17", name: "1.17" },
{ id: 2, slug: "1-17-1", name: "1.17.1" },
{ id: 3, slug: "1-18-Snapshot", name: "1.18-Snapshot" },
{ id: 4, slug: "CB-1-4-6-R0-1", name: "CB 1.4.6-R0.1" },
{ id: 5, slug: "risugamis-modloader", name: "Risugami's Modloader" },
]) as unknown[] as CurseForgeGameVersion[];

test("returns the correct IDs when using the default comparer", () => {
Expand Down Expand Up @@ -144,6 +145,15 @@ describe("findCurseForgeGameVersionIdsByNames", () => {

expect(result).toEqual(ids);
});

test("returns also based on slug", () => {
const names = ["risugamis-modloader"];
const ids = [5];

const result = findCurseForgeGameVersionIdsByNames(versions, names);

expect(result).toEqual(ids);
});
});

describe("formatCurseForgeGameVersion", () => {
Expand Down Expand Up @@ -230,4 +240,23 @@ describe("formatCurseForgeGameVersionSnapshot", () => {

expect(result).toEqual(expected);
});

test("formats the game version correctly when the input is a beta version", () => {
const gameVersion = {
id: "b1.7.3",
version: {
major: 1,
minor: 0,
patch: 0,
},
isBeta: true,
isSnapshot: true,
} as GameVersion;

const expected = "Beta 1.7.3";

const result = formatCurseForgeGameVersionSnapshot(gameVersion);

expect(result).toEqual(expected);
});
});