Enforce string is passed to toUtf8Bytes (#4583).

This commit is contained in:
Richard Moore 2024-02-14 12:32:43 -05:00
parent 7f0e140d5e
commit f45bb87aef

@ -247,6 +247,7 @@ function getUtf8CodePoints(_bytes: BytesLike, onError?: Utf8ErrorFunc): Array<nu
* If %%form%% is specified, the string is normalized. * If %%form%% is specified, the string is normalized.
*/ */
export function toUtf8Bytes(str: string, form?: UnicodeNormalizationForm): Uint8Array { export function toUtf8Bytes(str: string, form?: UnicodeNormalizationForm): Uint8Array {
assertArgument(typeof(str) === "string", "invalid string value", "str", str);
if (form != null) { if (form != null) {
assertNormalize(form); assertNormalize(form);