Skip to content
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

Don't use locale-aware comparison for browser names #123

Merged
merged 1 commit into from Feb 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions index.js
Expand Up @@ -124,6 +124,12 @@ function generateFilter(sign, version) {
}
}

function compareStrings(a, b) {
if (a < b) return -1;
if (a > b) return +1;
return 0;
}

/**
* Return array of browsers by selection queries.
*
Expand Down Expand Up @@ -212,7 +218,6 @@ var browserslist = function (queries, opts) {

error('Unknown browser query `' + selection + '`');
});

result = result.map(function (i) {
var parts = i.split(' ');
var name = parts[0];
Expand All @@ -229,10 +234,10 @@ var browserslist = function (queries, opts) {
if ( FLOAT_RANGE.test(name1[1]) && FLOAT_RANGE.test(name2[1]) ) {
return parseFloat(name2[1]) - parseFloat(name1[1]);
} else {
return name2[1].localeCompare(name1[1]);
return compareStrings(name2[1], name1[1]);
}
} else {
return name1[0].localeCompare(name2[0]);
return compareStrings(name1[0], name2[0]);
}
});

Expand Down