Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const uploadNotepad = (username: string, token: string, syncId: string, notepad: ISyncedNotepad, passkey?: string): Observable =>
from(!!notepad.crypto && !!passkey ? encrypt(notepad, passkey) : of(notepad)).pipe(
concatMap(np =>
call<{ assetsToUpload: AssetList }>('upload', syncId, {
notepadV2: JSON.stringify(np, (k, v) => (k === 'parent') ? undefined : v) // Remove parent links here, unneeded content
.replace(
/[\u007f-\uffff]/g,
char => '\\u' + ('0000' + char.charCodeAt(0).toString(16)).slice(-4)
), // Fix unicode encoding
username,
token
})
),
map(res => res.assetsToUpload)
);