Skip to content

Commit

Permalink
fix: make validation logic work by passing the raw map
Browse files Browse the repository at this point in the history
  • Loading branch information
tale committed Mar 11, 2022
1 parent 9dd959a commit 55b9511
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions src/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,15 @@ 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',
'Maintainer',
'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()
Expand Down
7 changes: 3 additions & 4 deletions src/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit 55b9511

Please sign in to comment.