Closed MartinKolarik closed 8 years ago
@MartinKolarik why don't you just send this a patch to https://github.com/megawac/semvish? It was literally written for libgrabber. I would be hesitant to merge this in as it may have other consequences (i.e. regressions in version support)
I would also consider this a bug in underscore.string
s natural compare.
Anyway @MartinKolarik its a very simple fix which you can implement by changing this loop to convert strings to numbers...
@megawac I agree this particular case would be easy to fix in semvish, but it is not the only problem I encountered using it. I switched to this sorting algorithm in api after discovering about 40 projects had empty versions
because semvish couldn't parse them.
I would normally send a PR to semvish, but I don't believe semvish is the best solution in this case. It relies on semver, and some versioning schemes simply can't be normalized to semver (e.g. what do we do with w.x.y.z
?).
I would be hesitant to merge this in as it may have other consequences (i.e. regressions in version support)
I used the regexp from semvish.clean()
exactly to prevent this. As for the sorting, I've already checked that it works just as well as semvish before using it for the API.
I will merge it and deploy because we have projects not updating. If there is a better solution we can work on it while no projects are failing :)
what do we do with w.x.y.z?
That gets parsed as w.x.y-z
. The only case that would be an issue is if the author also publishes w.x.y
as w.x.y > w.x.y-z
Anyway, thats obviously a bug and would have been fixed if it had been reported. However, bot is parsing some versions incorrectly now. See https://github.com/jsdelivr/jsdelivr/pull/10143
You're going to fix this by replacing a library, rather than putting a pull request in there?