Skip to content

Commit fe396dd

Browse files
committed
fix a regression with TMX map loading relatrd to a semver version comparaison issue
1 parent 1043d63 commit fe396dd

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [16.1.3] (melonJS 2) - _2024-02-13_
4+
5+
### Fixed
6+
- Loader: fix a regression with TMX map loading related to a semver version comparaison (`compare()` requires a "x.y.z" version format)
7+
38
## [16.1.2] (melonJS 2) - _2024-02-12_
49

510
### Fixed
@@ -747,7 +752,8 @@
747752

748753
-------------------------------------------------------------------------------
749754

750-
[16.1.0]: https://github.com/melonjs/melonJS/compare/16.1.1...16.1.2
755+
[16.1.3]: https://github.com/melonjs/melonJS/compare/16.1.2...16.1.3
756+
[16.1.2]: https://github.com/melonjs/melonJS/compare/16.1.1...16.1.2
751757
[16.1.1]: https://github.com/melonjs/melonJS/compare/16.2.0...16.1.1
752758
[16.1.0]: https://github.com/melonjs/melonJS/compare/16.0.0...16.1.0
753759
[16.0.0]: https://github.com/melonjs/melonJS/compare/15.15.0...16.0.0

src/utils/utils.js

+11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ let GUID_index = 0;
3333
* }
3434
*/
3535
export function checkVersion(v1, v2) {
36+
// Convert to proper "x.y.z" format if necessary
37+
if (/^\d+$/.test(v1)) {
38+
v1 += ".0.0";
39+
} else if (/^\d+\.\d+$/.test(v1)) {
40+
v1 += ".0";
41+
}
42+
if (/^\d+$/.test(v2)) {
43+
v2 += ".0.0";
44+
} else if (/^\d+\.\d+$/.test(v2)) {
45+
v2 += ".0";
46+
}
3647
return compare(v1, v2);
3748
}
3849

tests/browser/spec/utils-spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,18 @@ describe("utils", function () {
165165
// < 0 if the second string is greater
166166
// === 0 if the strings are equal
167167
expect(me.utils.checkVersion("15.13.0", "15.12.0") > 0).toEqual(true);
168+
expect(me.utils.checkVersion("15.13", "15.12.0") > 0).toEqual(true);
169+
expect(me.utils.checkVersion("16", "15.12.0") > 0).toEqual(true);
170+
expect(me.utils.checkVersion("16", "15") > 0).toEqual(true);
168171
expect(me.utils.checkVersion("7.0.0", "15.5.0") < 0).toEqual(true);
169172
expect(me.utils.checkVersion("15.12.0", "15.12.0") === 0).toEqual(true);
173+
expect(me.utils.checkVersion("15.12.0", "15.12") === 0).toEqual(true);
174+
expect(me.utils.checkVersion("15.0.0", "15.0") === 0).toEqual(true);
175+
expect(me.utils.checkVersion("15.0.0", "15") === 0).toEqual(true);
170176
expect(me.utils.checkVersion("15.12.1", "16.1.1") < 0).toEqual(true);
177+
expect(me.utils.checkVersion("15.12.1", "16.1") < 0).toEqual(true);
178+
expect(me.utils.checkVersion("15.12.1", "16") < 0).toEqual(true);
179+
expect(me.utils.checkVersion("15", "16") < 0).toEqual(true);
171180
});
172181
});
173182
});

0 commit comments

Comments
 (0)