mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Derive mod filename from name and version
Enforce the filename of uploaded mods match {name}_{version}.zip with
name and version taken from the zip file's info.json entry. This allows
it to be used as a unique key for the mod and solves part of the issues
with mods having different number of leading zeros in their version.
This commit is contained in:
1 parent
7d34c60dd1
commit
7072b94355
7 files changed
+39
-28
No files matched your search
@@ -9,6 +9,7 @@
|
||||
* number of leading zeros in them.
|
||||
* @param {string} version - string representation of version.
|
||||
* @returns {number} numeric representation.
|
||||
* @private
|
||||
*/
|
||||
function integerModVersion(version) {
|
||||
const [major, minor, sub] = version.split(".").map(n => Number.parseInt(n, 10));
|
||||
@@ -22,13 +23,22 @@ function integerModVersion(version) {
|
||||
* number of leading zeros in them.
|
||||
* @param {string} version - string representation of version.
|
||||
* @returns {number} numeric representation.
|
||||
* @private
|
||||
*/
|
||||
function integerFactorioVersion(version) {
|
||||
const [major, minor, sub] = version.split(".").map(n => Number.parseInt(n, 10));
|
||||
return major * 0x100000000 + minor * 0x10000 + (sub || 0); // Can't use bitwise here because this is 48-bits.
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches valid mod versions.
|
||||
* @type {RegExp}
|
||||
* @private
|
||||
*/
|
||||
const modVersionRegExp = /^\d+\.\d+\.\d+$/;
|
||||
|
||||
module.exports = {
|
||||
integerModVersion,
|
||||
integerFactorioVersion,
|
||||
modVersionRegExp,
|
||||
};
|
||||
Reference in new issue
Block a user