New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Users/elendil326/compare versions as integers #55
Users/elendil326/compare versions as integers #55
Conversation
…w is a string comparison, it should be an integer comparison.
tasks/common/apiHelper.ts
Outdated
} | ||
|
||
// Min set of common segments is equal, check for extra segments greater than zero | ||
var longerVersion = minLengthToCompare == xParts.length ? yParts : xParts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider simplifying by pushing 0's to the lesser array, xParts or yParts, to make them equal in length
tasks/common/apiHelper.ts
Outdated
if (diff) { | ||
return diff; | ||
} | ||
var shorterVersion = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
while (xParts.length < yParts.length) xParts.push('0');
while (yParts.length < xParts.length) yParts.push('0');
// Compare parts
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Adding version comparison as numbers rather than strings.