Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle edge cases during string measuring #141

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-terms-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@trustnxt/c2pa-ts': patch
---

Handle edge cases during string measuring
2 changes: 1 addition & 1 deletion src/jumbf/DescriptionBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class DescriptionBoxSchema extends BoxSchema<DescriptionBox> {
return measurer.add(
this.uuid.measure(value.uuid).size +
1 + // toggles
(value.label ? value.label.length + 1 : 0) +
(value.label ? this.label.measure(value.label).size : 0) +
(value.id ? 4 : 0) +
(value.hash ? 32 : 0) +
value.privateBoxes.reduce((acc, box) => acc + box.schema.measure(box).size, 0),
Expand Down
2 changes: 1 addition & 1 deletion src/jumbf/EmbeddedFileDescriptionBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EmbeddedFileDescriptionBoxSchema extends BoxSchema<EmbeddedFileDescription
measureContent(value: EmbeddedFileDescriptionBox, measurer: bin.IMeasurer): bin.IMeasurer {
return measurer.add(
1 + // flags
this.mediaType.measure(value.mediaType ?? '').size +
(value.mediaType ? this.mediaType.measure(value.mediaType).size : 0) +
(value.fileName ? this.fileName.measure(value.fileName).size : 0),
);
}
Expand Down
Loading