From 55b95116d2b12216af3af62bd3248c54a6992234 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Fri, 11 Mar 2022 13:20:08 -0500 Subject: [PATCH] fix: make validation logic work by passing the raw map --- src/base.ts | 4 ++-- src/control.ts | 6 ++---- src/release.ts | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/base.ts b/src/base.ts index e43984d..4d3b06f 100644 --- a/src/base.ts +++ b/src/base.ts @@ -36,8 +36,8 @@ export class APTBase { * Base constructor. * This should never be used. */ - constructor(required: string[]) { - this.raw = new CaseCopyMap() + constructor(raw: CaseCopyMap, required: string[]) { + this.raw = raw this.required = required for (const key of this.required) { diff --git a/src/control.ts b/src/control.ts index 588bcdc..f3cf1e3 100644 --- a/src/control.ts +++ b/src/control.ts @@ -262,7 +262,8 @@ export class BinaryControl extends APTBase implements IBinaryControl { * @param {string} rawData Contents of a control file from a debian binary */ constructor(rawData: string) { - super([ + const map = parseKV(rawData) + super(map, [ 'Package', 'Version', 'Architecture', @@ -270,9 +271,6 @@ export class BinaryControl extends APTBase implements IBinaryControl { 'Description' ]) - const map = parseKV(rawData) - this.raw = map - this.package = map.get('Package')!.trim() this.source = map.get('Source')?.trim() this.version = map.get('Version')!.trim() diff --git a/src/release.ts b/src/release.ts index 2c78643..6584bb3 100644 --- a/src/release.ts +++ b/src/release.ts @@ -259,14 +259,13 @@ export class Release extends APTBase implements IRelease { * @param {string} rawData Contents of a Release file from an APT repository */ constructor(rawData: string) { - super([ + const map = parseKV(rawData) + + super(map, [ 'Architectures', 'Components' ]) - const map = parseKV(rawData) - this.raw = map - this.architectures = map.get('Architectures')!.trim().split(' ') this.noSupportForArchitectureAll = parseBoolean(map.get('No-Support-For-Architecture-All')?.trim())