diff options
| author | dakkar <dakkar@thenautilus.net> | 2024-02-03 11:29:46 +0000 |
|---|---|---|
| committer | dakkar <dakkar@thenautilus.net> | 2024-02-03 11:29:46 +0000 |
| commit | 25948c9232156e553374ccaa8917c004e1f35fdd (patch) | |
| tree | 1fb5eaae2d2645a9568c6c1f2f7269c2c3cb331d /packages/backend/src/queue | |
| parent | Merge branch 'chore/updateMarkdownAndTemplates' into 'develop' (diff) | |
| download | sharkey-25948c9232156e553374ccaa8917c004e1f35fdd.tar.gz sharkey-25948c9232156e553374ccaa8917c004e1f35fdd.tar.bz2 sharkey-25948c9232156e553374ccaa8917c004e1f35fdd.zip | |
simpler json-isation
thanks Alina for the suggestion
Diffstat (limited to 'packages/backend/src/queue')
| -rw-r--r-- | packages/backend/src/queue/processors/ImportNotesProcessorService.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/packages/backend/src/queue/processors/ImportNotesProcessorService.ts b/packages/backend/src/queue/processors/ImportNotesProcessorService.ts index e5177d28e5..0554566748 100644 --- a/packages/backend/src/queue/processors/ImportNotesProcessorService.ts +++ b/packages/backend/src/queue/processors/ImportNotesProcessorService.ts @@ -130,11 +130,11 @@ export class ImportNotesProcessorService { return typeof obj[Symbol.iterator] === 'function'; } - private parseTwitterFile(str : string) : null | [{ tweet: any }] { - const removed = str.replace(new RegExp('window\\.YTD\\.tweets\\.part0 = ', 'g'), ''); - + private parseTwitterFile(str : string) : null | { tweet: object }[] { + const jsonStr = str.replace(/^\s*window\.YTD\.tweets\.part0\s*=\s*/, ''); + try { - return JSON.parse(removed); + return JSON.parse(jsonStr); } catch (error) { //The format is not what we expected. Either this file was tampered with or twitters exports changed return null; |