mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Add MajorMinorVersion type and dedupe the game version regex
Address review feedback: introduce a MajorMinorVersion type with isMajorMinorVersion, rename majorMinorVersion to normaliseMajorMinorVersion, and type ModInfo.factorioVersion as MajorMinorVersion so already-reduced values are not re-reduced (ModPackViewPage uses mod.info.factorioVersion directly). Reuse the single gameVersionRegExp in both GameVersionSchema and normaliseGameVersion instead of duplicating the pattern. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
97a6c32838
commit
7c2793752d
6 files changed
+47
-21
No files matched your search
@@ -39,11 +39,23 @@ describe("lib/data/version", function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
describe("majorMinorVersion()", function() {
|
||||
describe("normaliseMajorMinorVersion()", function() {
|
||||
it("should return the major.minor", function() {
|
||||
assert.equal(lib.majorMinorVersion("1.1"), "1.1");
|
||||
assert.equal(lib.majorMinorVersion("1.1.50"), "1.1");
|
||||
assert.equal(lib.majorMinorVersion("0.18.0"), "0.18");
|
||||
assert.equal(lib.normaliseMajorMinorVersion("1.1"), "1.1");
|
||||
assert.equal(lib.normaliseMajorMinorVersion("1.1.50"), "1.1");
|
||||
assert.equal(lib.normaliseMajorMinorVersion("0.18.0"), "0.18");
|
||||
});
|
||||
});
|
||||
describe("isMajorMinorVersion()", function() {
|
||||
it("should correctly validate input strings", function() {
|
||||
const valid = ["1.1", "0.18", "2.0", "10.20"];
|
||||
const invalid = ["1", "1.1.0", "1.1.50", "latest", "1.", ".1", ""];
|
||||
for (const version of valid) {
|
||||
assert(lib.isMajorMinorVersion(version), `${version} should be valid`);
|
||||
}
|
||||
for (const version of invalid) {
|
||||
assert(!lib.isMajorMinorVersion(version), `${version} should be invalid`);
|
||||
}
|
||||
});
|
||||
});
|
||||
describe("isFullVersion()", function() {
|
||||
|
||||
Reference in new issue
Block a user