1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 15:32:28 +02:00

Fix rule sorting quirk in "My rules" pane

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1055
This commit is contained in:
Raymond Hill 2020-08-27 07:04:37 -04:00
parent 45cce88d8b
commit d2195b4246
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -385,28 +385,30 @@ const onPresentationChanged = (( ) => {
const reSwRule = /^([^/]+): ([^/ ]+) ([^ ]+)/;
const reRule = /^([^ ]+) ([^/ ]+) ([^ ]+ [^ ]+)/;
const reUrlRule = /^([^ ]+) ([^ ]+) ([^ ]+ [^ ]+)/;
const reUrlRule = /^([^ ]+) ([^ ]+) ([^ ]+ [^ ]+)/;
const reverseHn = function(hn) {
return hn.split('.').reverse().join('.');
};
const slotFromRule = rule => {
let type, srcHn, desHn, extra = '';
let type, srcHn, desHn, extra;
let match = reSwRule.exec(rule);
if ( match !== null ) {
type = ' ' + match[1];
srcHn = reverseHn(match[2]);
desHn = srcHn;
extra = match[3];
} else if ( (match = reRule.exec(rule)) !== null ) {
type = '\x10FFFE';
srcHn = reverseHn(match[1]);
desHn = reverseHn(match[2]);
extra = match[3];
} else if ( (match = reUrlRule.exec(rule)) !== null ) {
type = '\x10FFFF';
srcHn = reverseHn(match[1]);
desHn = reverseHn(vAPI.hostnameFromURI(match[2]));
extra = rule;
extra = match[3];
}
if ( sortType === 0 ) {
return { rule, token: `${type} ${srcHn} ${desHn} ${extra}` };