Skip to content

Commit

Permalink
Set default identifierType to None in ResourceLocator
Browse files Browse the repository at this point in the history
Initialized `identifierType` to `ResourceLocatorIdentifierEnum.None` by default in the `ResourceLocator` model. Removed redundant assignment in constructor and adjusted identifier length calculation accordingly.
  • Loading branch information
pflynn-virtru committed Aug 15, 2024
1 parent 3ef7670 commit 42211e6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/src/nanotdf/models/ResourceLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class ResourceLocator {
readonly lengthOfBody: number;
readonly body: string;
readonly identifier: string;
readonly identifierType: ResourceLocatorIdentifierEnum;
readonly identifierType: ResourceLocatorIdentifierEnum = ResourceLocatorIdentifierEnum.None;
readonly offset: number = 0;

static readonly PROTOCOL_OFFSET = 0;
Expand Down Expand Up @@ -86,7 +86,6 @@ export default class ResourceLocator {
buff.subarray(ResourceLocator.BODY_OFFSET, ResourceLocator.BODY_OFFSET + this.lengthOfBody)
);
// identifier
this.identifierType = ResourceLocatorIdentifierEnum.None;
const identifierTypeNibble = this.protocol & 0xf;
if ((identifierTypeNibble & 0b0010) !== 0) {
this.identifierType = ResourceLocatorIdentifierEnum.TwoBytes;
Expand Down Expand Up @@ -131,7 +130,7 @@ export default class ResourceLocator {
// Content length
this.body.length +
// Identifier length
this.identifier.length
this.identifierType.valueOf()
);
}

Expand Down

0 comments on commit 42211e6

Please sign in to comment.