uael / sv

libsv - Public domain cross-platform semantic versioning in c99

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

failed to parse build number with zero prefix

waruqi opened this issue · comments

commented

When I parse the string and numeric build number, it works normally, but if there is a 0 prefix in the build number, the parsing fails

Is this a specification requirement for the semantic version? Or is it a bug?

^(?P0|[1-9]\d*).(?P0|[1-9]\d*).(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-])(?:.(?:0|[1-9]\d|\d*[a-zA-Z-][0-9a-zA-Z-]))))?(?:+(?P[0-9a-zA-Z-]+(?:.[0-9a-zA-Z-]+)*))?$

I saw the specification, build metadata can contain zero prefix.

1.0.1+HEAD.1234

It works, build: {HEAD, 1234}

1.0.1+HEAD.01234

It does not work, parse 01234 failed

sv/src/id.c

Lines 68 to 70 in a1af47b

} else if (is_zero) {
return 1;
}

commented

there is an online checker. https://jubianchi.github.io/semver-check/#/1.0.1%2BHEAD.001/1.0.1%2BHEAD.001

The zero prefix constraint may only be valid for prerelease.

commented

I open a pr to try fix it. #52

Thanks mate 👍