Skip to content

Commit eadc196

Browse files
committed
Prevent making an unnecessary copy when encoding bytes.
1 parent 5f9bd88 commit eadc196

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# @digitalbazaar/http-digest-header Changelog
22

3+
## 2.2.1 - 2025-10-dd
4+
5+
### Fixed
6+
- Prevent making an unnecessary copy when encoding bytes.
7+
38
## 2.2.0 - 2025-10-08
49

510
### Changed

lib/util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
* Copyright (c) 2021-2025 Digital Bazaar, Inc. All rights reserved.
33
*/
44
export function base64Encode(bytes) {
5-
return Buffer.from(bytes).toString('base64');
5+
return Buffer.from(bytes.buffer, bytes.offset, bytes.length)
6+
.toString('base64');
67
}
78

89
export function base64urlEncode(bytes) {
9-
return Buffer.from(bytes).toString('base64url');
10+
return Buffer.from(bytes.buffer, bytes.offset, bytes.length)
11+
.toString('base64url');
1012
}

0 commit comments

Comments
 (0)