Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Convert `lib/encoding` to TypeScript (#69413)

Frasera6bf8e9326da
diff --git a/frontend/src/metabase/lib/encoding.js b/frontend/src/metabase/lib/encoding.ts
similarity index 69%
rename from frontend/src/metabase/lib/encoding.js
rename to frontend/src/metabase/lib/encoding.ts
index 47325a4a9f9..d2395af7ece 100644
--- a/frontend/src/metabase/lib/encoding.js
+++ b/frontend/src/metabase/lib/encoding.ts
@@ -1,22 +1,22 @@
// escaping before base64 encoding is necessary for non-ASCII characters
// https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/btoa
-export function utf8_to_b64(str) {
+export function utf8_to_b64(str: string) {
return window.btoa(unescape(encodeURIComponent(str)));
}
-export function b64_to_utf8(b64) {
+export function b64_to_utf8(b64: string) {
return decodeURIComponent(escape(window.atob(b64)));
}
// for "URL safe" base64, replace "+" with "-" and "/" with "_" as per RFC 4648
-export function utf8_to_b64url(str) {
+export function utf8_to_b64url(str: string) {
return utf8_to_b64(str).replace(/\+/g, "-").replace(/\//g, "_");
}
-export function b64url_to_utf8(b64url) {
+export function b64url_to_utf8(b64url: string) {
return b64_to_utf8(b64url.replace(/-/g, "+").replace(/_/g, "/"));
}
-export function b64hash_to_utf8(b64hash) {
+export function b64hash_to_utf8(b64hash: string) {
return b64url_to_utf8(b64hash.replace(/^#/, ""));
}