Skip to content
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 components/utils/base-64.utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ describe("base-64.utils", () => {
expect(fromBase64(wrapped)).toBe(message);
});

test("should decode base64 of multiline text", () => {
const multiline = "This is the first line\n\nthis is another one";
expect(fromBase64(toBase64(multiline))).toBe(multiline);
});

test("should throw an error for an invalid Base64 string", () => {
expect(() => fromBase64("invalid_base64")).toThrow(
"Invalid Base64 input"
Expand Down
5 changes: 3 additions & 2 deletions components/utils/base-64.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ export function fromBase64(value: string): string {

/**
* Checks if the given string consists entirely of printable ASCII characters.
* Printable ASCII characters are those in the range from space (0x20) to tilde (0x7E).
* Printable ASCII characters are those in the range from space (0x20) to tilde (0x7E),
* plus common whitespace characters (tab, carriage return, line feed).
*/
export function isPrintableASCII(str: string): boolean {
return /^[\x20-\x7E]*$/.test(str);
return /^[\x20-\x7E\t\r\n]*$/.test(str);
}