santinic / how2

AI for the Command Line
https://how2terminal.com
MIT License
5.72k stars 156 forks source link

`later` in 'updates.js' uses string comparison instead of int comparison. #43

Closed danyshaanan closed 8 years ago

danyshaanan commented 8 years ago

https://github.com/santinic/how2/blob/master/lib/updates.js#L9-L17

 function later(a, b) {
        var as = a.split('.');
        var bs = b.split('.');
        for(var i=0; i<3; i++) {
            if(as[i] > bs[i])
                return true;
        }
        return false;
    }
later('1.0.9','1.0.10')

This returns true, as the string '9' is later lexicographically than the string '10'.

This can be resolved using semver as can be seen here.

If this seems right, I could make the changes with a PR.

santinic commented 8 years ago

man you're amazing :) +1: please do it if you have time. May magic goodness happen in your life

danyshaanan commented 8 years ago

Will do, probably later today :]