From a0548fbc4c2c444a21d047e81f0405f80bcc4382 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Sat, 11 Jun 2022 19:30:48 +0530 Subject: [PATCH] fix: add more escape chars for multi file auth state --- src/Utils/use-multi-file-auth-state.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Utils/use-multi-file-auth-state.ts b/src/Utils/use-multi-file-auth-state.ts index 1776165..69f909b 100644 --- a/src/Utils/use-multi-file-auth-state.ts +++ b/src/Utils/use-multi-file-auth-state.ts @@ -44,14 +44,7 @@ export const useMultiFileAuthState = async(folder: string): Promise<{ state: Aut await mkdir(folder, { recursive: true }) } - const fixFileName = (file) =>{ - if(file){ - return file.replace(/:/g, '-'); - } - else { - return file - } - } + const fixFileName = (file?: string) => file?.replace(/\//g, '__')?.replace(/:/g, '-') const creds: AuthenticationCreds = await readData('creds.json') || initAuthCreds() @@ -65,7 +58,7 @@ export const useMultiFileAuthState = async(folder: string): Promise<{ state: Aut ids.map( async id => { let value = await readData(`${type}-${id}.json`) - if(type === 'app-state-sync-key') { + if(type === 'app-state-sync-key' && value) { value = proto.AppStateSyncKeyData.fromObject(value) }