Skip to content

Commit

Permalink
Make ghostery_id optional
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp-classen committed Aug 3, 2023
1 parent 10f6097 commit 23fbd2c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/adblocker/src/engine/metadata/patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface IPattern {
readonly organization: string | null;
readonly alias: string | null;
readonly website_url: string | null;
readonly ghostery_id: string;
readonly ghostery_id: string | null;
readonly domains: string[];
readonly filters: string[];
}
Expand Down Expand Up @@ -73,10 +73,6 @@ export function isValid(pattern: any): pattern is IPattern {
return false;
}

if (typeof ghosteryId !== 'string') {
return false;
}

if (!Array.isArray(domains) || !domains.every((domain) => typeof domain === 'string')) {
return false;
}
Expand Down Expand Up @@ -126,7 +122,7 @@ export function getSerializedSize(pattern: IPattern): number {
sizeOfUTF8(pattern.organization || '') +
sizeOfUTF8(pattern.alias || '') +
sizeOfUTF8(pattern.website_url || '') +
sizeOfUTF8(pattern.ghostery_id) +
sizeOfUTF8(pattern.ghostery_id || '') +
sizeOfDomains +
sizeOfFilters
);
Expand All @@ -139,7 +135,7 @@ export function serialize(pattern: IPattern, view: StaticDataView) {
view.pushUTF8(pattern.organization || '');
view.pushUTF8(pattern.alias || '');
view.pushUTF8(pattern.website_url || '');
view.pushUTF8(pattern.ghostery_id);
view.pushUTF8(pattern.ghostery_id || '');

view.pushLength(pattern.domains.length);
for (const domain of pattern.domains) {
Expand All @@ -159,7 +155,7 @@ export function deserialize(view: StaticDataView): IPattern {
const organization = view.getUTF8() || null;
const alias = view.getUTF8() || null;
const website_url = view.getUTF8() || null;
const ghostery_id = view.getUTF8();
const ghostery_id = view.getUTF8() || null;

const numberOfDomains = view.getLength();
const domains = [];
Expand Down

0 comments on commit 23fbd2c

Please sign in to comment.