mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-18 17:02:27 +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:
parent
45cce88d8b
commit
d2195b4246
@ -385,28 +385,30 @@ const onPresentationChanged = (( ) => {
|
|||||||
|
|
||||||
const reSwRule = /^([^/]+): ([^/ ]+) ([^ ]+)/;
|
const reSwRule = /^([^/]+): ([^/ ]+) ([^ ]+)/;
|
||||||
const reRule = /^([^ ]+) ([^/ ]+) ([^ ]+ [^ ]+)/;
|
const reRule = /^([^ ]+) ([^/ ]+) ([^ ]+ [^ ]+)/;
|
||||||
const reUrlRule = /^([^ ]+) ([^ ]+) ([^ ]+ [^ ]+)/;
|
const reUrlRule = /^([^ ]+) ([^ ]+) ([^ ]+ [^ ]+)/;
|
||||||
|
|
||||||
const reverseHn = function(hn) {
|
const reverseHn = function(hn) {
|
||||||
return hn.split('.').reverse().join('.');
|
return hn.split('.').reverse().join('.');
|
||||||
};
|
};
|
||||||
|
|
||||||
const slotFromRule = rule => {
|
const slotFromRule = rule => {
|
||||||
let type, srcHn, desHn, extra = '';
|
let type, srcHn, desHn, extra;
|
||||||
let match = reSwRule.exec(rule);
|
let match = reSwRule.exec(rule);
|
||||||
if ( match !== null ) {
|
if ( match !== null ) {
|
||||||
type = ' ' + match[1];
|
type = ' ' + match[1];
|
||||||
srcHn = reverseHn(match[2]);
|
srcHn = reverseHn(match[2]);
|
||||||
desHn = srcHn;
|
desHn = srcHn;
|
||||||
|
extra = match[3];
|
||||||
} else if ( (match = reRule.exec(rule)) !== null ) {
|
} else if ( (match = reRule.exec(rule)) !== null ) {
|
||||||
type = '\x10FFFE';
|
type = '\x10FFFE';
|
||||||
srcHn = reverseHn(match[1]);
|
srcHn = reverseHn(match[1]);
|
||||||
desHn = reverseHn(match[2]);
|
desHn = reverseHn(match[2]);
|
||||||
|
extra = match[3];
|
||||||
} else if ( (match = reUrlRule.exec(rule)) !== null ) {
|
} else if ( (match = reUrlRule.exec(rule)) !== null ) {
|
||||||
type = '\x10FFFF';
|
type = '\x10FFFF';
|
||||||
srcHn = reverseHn(match[1]);
|
srcHn = reverseHn(match[1]);
|
||||||
desHn = reverseHn(vAPI.hostnameFromURI(match[2]));
|
desHn = reverseHn(vAPI.hostnameFromURI(match[2]));
|
||||||
extra = rule;
|
extra = match[3];
|
||||||
}
|
}
|
||||||
if ( sortType === 0 ) {
|
if ( sortType === 0 ) {
|
||||||
return { rule, token: `${type} ${srcHn} ${desHn} ${extra}` };
|
return { rule, token: `${type} ${srcHn} ${desHn} ${extra}` };
|
||||||
|
Loading…
Reference in New Issue
Block a user