mirror of
https://github.com/revanced/revanced-website.git
synced 2025-04-29 22:24:31 +02:00
fix(patches): properly search for package name
This commit is contained in:
parent
e1b37fab7d
commit
c7d31cf01b
@ -28,18 +28,15 @@
|
|||||||
let timeout: any = null;
|
let timeout: any = null;
|
||||||
let mobilePackages = false;
|
let mobilePackages = false;
|
||||||
|
|
||||||
function checkCompatibility(patch: Patch, pkg: string, cmp: (a: string, b: string) => boolean) {
|
function checkCompatibility(patch: Patch, pkg: string) {
|
||||||
if (pkg === '') {
|
if (pkg === '') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !!patch.compatiblePackages.find((compat) => cmp(compat.name, pkg));
|
return !!patch.compatiblePackages.find((compat) => compat.name === pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchString(str: string, term: string, replacement_regex: RegExp) {
|
function searchString(str: string, term: string, filter: RegExp) {
|
||||||
return str
|
return str.toLowerCase().replace(filter, '').includes(term);
|
||||||
.toLowerCase()
|
|
||||||
.replace(replacement_regex, '')
|
|
||||||
.includes(term || '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter(patches: Patch[], pkg: string, search?: string): Patch[] {
|
function filter(patches: Patch[], pkg: string, search?: string): Patch[] {
|
||||||
@ -49,7 +46,7 @@
|
|||||||
|
|
||||||
return patches.filter((patch) => {
|
return patches.filter((patch) => {
|
||||||
// Don't show if the patch doesn't support the selected package
|
// Don't show if the patch doesn't support the selected package
|
||||||
if (pkg && !checkCompatibility(patch, pkg, (a, b) => a === b)) {
|
if (pkg && !checkCompatibility(patch, pkg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +55,7 @@
|
|||||||
return (
|
return (
|
||||||
searchString(patch.description, search, /\s/g) ||
|
searchString(patch.description, search, /\s/g) ||
|
||||||
searchString(patch.name, search, /-/g) ||
|
searchString(patch.name, search, /-/g) ||
|
||||||
checkCompatibility(patch, pkg, (a, b) => searchString(a, b, /\./g))
|
patch.compatiblePackages.find((x) => searchString(x.name, search, /\./g))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user