|
@@ -514,15 +514,22 @@ export async function fileEqual(linesA: string[], source: AsyncIterable<string>
|
|
|
|
|
|
|
|
const lineA = linesA[index];
|
|
const lineA = linesA[index];
|
|
|
|
|
|
|
|
- if (lineA.length === 0 && lineB.length === 0) {
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ if (lineA.length === 0) {
|
|
|
|
|
+ if (lineB.length === 0) {
|
|
|
|
|
+ // both lines are empty, check next line
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ // lineA is empty but lineB is not
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // not both line are empty
|
|
|
|
|
- if (lineA.length === 0 || lineB.length === 0) {
|
|
|
|
|
|
|
+ // now lineA can not be empty
|
|
|
|
|
+ if (lineB.length === 0) {
|
|
|
|
|
+ // lineB is empty but lineA is not
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // now both lines can not be empty
|
|
|
|
|
+
|
|
|
const firstCharA = lineA.charCodeAt(0);
|
|
const firstCharA = lineA.charCodeAt(0);
|
|
|
const firstCharB = lineB.charCodeAt(0);
|
|
const firstCharB = lineB.charCodeAt(0);
|
|
|
|
|
|
|
@@ -530,16 +537,17 @@ export async function fileEqual(linesA: string[], source: AsyncIterable<string>
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (firstCharA === 35 /* # */ && firstCharB === 35 /* # */) {
|
|
|
|
|
|
|
+ // now firstCharA is equal to firstCharB, we only need to check the first char
|
|
|
|
|
+ if (firstCharA === 35 /* # */) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
// adguard conf
|
|
// adguard conf
|
|
|
- if (firstCharA === 33 /* ! */ && firstCharB === 33 /* ! */) {
|
|
|
|
|
|
|
+ if (firstCharA === 33 /* ! */) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
if (
|
|
|
- firstCharA === 47 /* / */ && firstCharB === 47 /* / */
|
|
|
|
|
|
|
+ firstCharA === 47 /* / */
|
|
|
&& lineA[1] === '/' && lineB[1] === '/'
|
|
&& lineA[1] === '/' && lineB[1] === '/'
|
|
|
&& lineA[3] === '#' && lineB[3] === '#'
|
|
&& lineA[3] === '#' && lineB[3] === '#'
|
|
|
) {
|
|
) {
|