refactor: delete base64js
instead of base64 library you can use built-in JS functions `btoa()` and `atob()`
This commit is contained in:
@@ -39,17 +39,6 @@ function cpuCoreFormat(cores) {
|
||||
}
|
||||
}
|
||||
|
||||
function base64(str) {
|
||||
return Base64.encode(str);
|
||||
}
|
||||
|
||||
function safeBase64(str) {
|
||||
return base64(str)
|
||||
.replace(/\+/g, '-')
|
||||
.replace(/=/g, '')
|
||||
.replace(/\//g, '_');
|
||||
}
|
||||
|
||||
function formatSecond(second) {
|
||||
if (second < 60) {
|
||||
return second.toFixed(0) + 's';
|
||||
|
||||
@@ -478,4 +478,21 @@ class Wireguard {
|
||||
privateKey: secretKey.length > 0 ? secretKey : this.keyToBase64(privateKey)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Base64 {
|
||||
static encode(content = "", safe = false) {
|
||||
if (safe) {
|
||||
return window.btoa(content)
|
||||
.replace(/\+/g, '-')
|
||||
.replace(/=/g, '')
|
||||
.replace(/\//g, '_')
|
||||
}
|
||||
|
||||
return window.btoa(content)
|
||||
}
|
||||
|
||||
static decode(content = "") {
|
||||
return window.atob(content)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user