fix: Minecraft 1.20 crashing the semver parser #12

Merged
Ecorous merged 6 commits from fix/semver-crash-mc1.20 into main 2024-07-07 07:50:52 -04:00
Showing only changes of commit 28652b7e00 - Show all commits

View file

@ -30,7 +30,7 @@ public record SemVerImpl(int major, int minor, int patch, String prerelease, Str
int minor = Integer.parseInt(matcher.group("minor")); int minor = Integer.parseInt(matcher.group("minor"));
// minecraft treats the `patch` component as optional... // minecraft treats the `patch` component as optional...
@Nullable String patchString = matcher.group("patch"); @Nullable String patchString = matcher.group("patch");
int patch = patchString == null ? 0 : Integer.parseInt(matcher.group("patch")); int patch = patchString == null ? 0 : Integer.parseInt(patchString);
String prerelease = matcher.group("prerelease"); String prerelease = matcher.group("prerelease");
owlsys marked this conversation as resolved Outdated

nitpick: could use the previously assigned variable in the Integer.parseInt call

nitpick: could use the previously assigned variable in the `Integer.parseInt` call
Outdated
Review

wdym?

wdym?
int patch = patchString == null ? 0 : Integer.parseInt(matcher.group(patchString));
```java int patch = patchString == null ? 0 : Integer.parseInt(matcher.group(patchString)); ```
Outdated
Review

i'm not understanding sorry, what should i change it to?

i'm not understanding sorry, what should i change it to?
Outdated
Review

OH, got it, forgot to actually us the var i added lol

OH, got it, forgot to actually us the var i added lol
String buildmetadata = matcher.group("buildmetadata"); String buildmetadata = matcher.group("buildmetadata");
return new SemVerImpl(major, minor, patch, prerelease, buildmetadata); return new SemVerImpl(major, minor, patch, prerelease, buildmetadata);