@@ -50,6 +50,9 @@ const buf7 = Buffer.from('tést', 'latin1');
50
50
## Buffers and character encodings
51
51
<!-- YAML
52
52
changes:
53
+ - version: REPLACEME
54
+ pr-url: https://github.com/nodejs/node/pull/36952
55
+ description: Introduced `base64url` encoding.
53
56
- version: v6.4.0
54
57
pr-url: https://github.com/nodejs/node/pull/7111
55
58
description: Introduced `latin1` as an alias for `binary`.
@@ -106,6 +109,11 @@ string into a `Buffer` as decoding.
106
109
specified in [ RFC 4648, Section 5] [ ] . Whitespace characters such as spaces,
107
110
tabs, and new lines contained within the base64-encoded string are ignored.
108
111
112
+ * ` 'base64url' ` : [ base64url] [ ] encoding as specified in
113
+ [ RFC 4648, Section 5] [ ] . When creating a ` Buffer ` from a string, this
114
+ encoding will also correctly accept regular base64-encoded strings. When
115
+ encoding a ` Buffer ` to a string, this encoding will omit padding.
116
+
109
117
* ` 'hex' ` : Encode each byte as two hexadecimal characters. Data truncation
110
118
may occur when decoding strings that do exclusively contain valid hexadecimal
111
119
characters. See below for an example.
@@ -469,9 +477,10 @@ Returns the byte length of a string when encoded using `encoding`.
469
477
This is not the same as [ ` String.prototype.length ` ] [ ] , which does not account
470
478
for the encoding that is used to convert the string into bytes.
471
479
472
- For ` 'base64' ` and ` 'hex' ` , this function assumes valid input. For strings that
473
- contain non-base64/hex-encoded data (e.g. whitespace), the return value might be
474
- greater than the length of a ` Buffer ` created from the string.
480
+ For ` 'base64' ` , ` 'base64url' ` , and ` 'hex' ` , this function assumes valid input.
481
+ For strings that contain non-base64/hex-encoded data (e.g. whitespace), the
482
+ return value might be greater than the length of a ` Buffer ` created from the
483
+ string.
475
484
476
485
``` js
477
486
const str = ' \u00bd + \u00bc = \u00be ' ;
@@ -3427,6 +3436,7 @@ introducing security vulnerabilities into an application.
3427
3436
[ `buffer.kMaxLength` ] : #buffer_buffer_kmaxlength
3428
3437
[ `util.inspect()` ] : util.md#util_util_inspect_object_options
3429
3438
[ `v8::TypedArray::kMaxLength` ] : https://v8.github.io/api/head/classv8_1_1TypedArray.html#a54a48f4373da0850663c4393d843b9b0
3439
+ [ base64url ] : https://tools.ietf.org/html/rfc4648#section-5
3430
3440
[ binary strings ] : https://developer.mozilla.org/en-US/docs/Web/API/DOMString/Binary
3431
3441
[ endianness ] : https://en.wikipedia.org/wiki/Endianness
3432
3442
[ iterator ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
0 commit comments