mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 08:23:12 +09:00
Parse mod versions leniently like the game does
The mod portal "ApiVersion" enum was validated strictly when loading a mod's info.json, which rejected versions the game itself accepts. Versions are now normalised the same lenient way the game reads them: leading whitespace is allowed, the major and minor are required, the patch is optional, any trailing content is ignored, and numbers are read as integers. This applies to both a mod's version and its factorio_version, validated by a regex schema rather than the fixed enum. The enum is no longer used to validate versions at all - the mod portal is the source of truth, so its error is now surfaced when a version is unsupported. The known-version list kept for the web interface fallback gains 2.1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ce8bddad8f
commit
97a6c32838
10 files changed
+141
-81
No files matched your search
@@ -147,7 +147,7 @@ function SearchModsButton() {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [form] = Form.useForm();
|
||||
const [searchText, setSearchText] = useState("");
|
||||
const [factorioVersion, setFactorioVersion] = useState<lib.ApiVersion>("2.0");
|
||||
const [factorioVersion, setFactorioVersion] = useState<lib.PartialVersion>("2.0");
|
||||
|
||||
// State for all mods fetched from backend
|
||||
const [allMods, setAllMods] = useState<ModPortalModType[]>([]);
|
||||
@@ -165,7 +165,7 @@ function SearchModsButton() {
|
||||
modName: string,
|
||||
modTitle: string | undefined,
|
||||
modVersion: lib.FullVersion | undefined,
|
||||
portalFactorioVersion: lib.ApiVersion,
|
||||
portalFactorioVersion: lib.PartialVersion,
|
||||
) => {
|
||||
if (modVersion) {
|
||||
control.send(
|
||||
@@ -271,7 +271,7 @@ function SearchModsButton() {
|
||||
// Update search text and factorio version from form
|
||||
const handleSearch = (changedValues: any, allValues: any) => {
|
||||
const nameValue = allValues.name;
|
||||
const versionValue = allValues.factorioVersion as lib.ApiVersion | undefined;
|
||||
const versionValue = allValues.factorioVersion as lib.PartialVersion | undefined;
|
||||
|
||||
// Only trigger state updates if values actually changed
|
||||
if (nameValue !== searchText) {
|
||||
|
||||
Reference in new issue
Block a user