mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 17:30:46 +00:00
Copy To functionality for notebooks (#141)
* Add Copy To functionality for notebooks * Fix formatting * Fix linting errors * Fixes * Fix build failure * Rebase and address feedback * Increase test coverage
This commit is contained in:
11
src/Utils/Base64Utils.test.ts
Normal file
11
src/Utils/Base64Utils.test.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as Base64Utils from "./Base64Utils";
|
||||
|
||||
describe("Base64Utils", () => {
|
||||
describe("utf8ToB64", () => {
|
||||
it("should convert utf8 to base64", () => {
|
||||
expect(Base64Utils.utf8ToB64("abcd")).toEqual(btoa("abcd"));
|
||||
expect(Base64Utils.utf8ToB64("小飼弾")).toEqual("5bCP6aO85by+");
|
||||
expect(Base64Utils.utf8ToB64("à mon hôpital préféré")).toEqual("w6AgbW9uIGjDtHBpdGFsIHByw6lmw6lyw6k=");
|
||||
});
|
||||
});
|
||||
});
|
||||
7
src/Utils/Base64Utils.ts
Normal file
7
src/Utils/Base64Utils.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const utf8ToB64 = (utf8Str: string): string => {
|
||||
return btoa(
|
||||
encodeURIComponent(utf8Str).replace(/%([0-9A-F]{2})/g, (_, args) => {
|
||||
return String.fromCharCode(parseInt(args, 16));
|
||||
})
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user