From d78660692423ba00e2fc43aa1023fba7719b8730 Mon Sep 17 00:00:00 2001
From: Fedor Katurov <gotham48@gmail.com>
Date: Wed, 24 Feb 2021 14:36:15 +0700
Subject: [PATCH] fixed comment text splitting

---
 .env             |  5 -----
 src/utils/dom.ts | 12 +++++++-----
 2 files changed, 7 insertions(+), 10 deletions(-)
 delete mode 100644 .env

diff --git a/.env b/.env
deleted file mode 100644
index bfd29ef4..00000000
--- a/.env
+++ /dev/null
@@ -1,5 +0,0 @@
-#API_HOST = http://localhost:7777/
-#REMOTE_CURRENT = http://localhost:7777/static/
-REACT_APP_API_HOST = https://pig.staging.vault48.org/
-REACT_APP_REMOTE_CURRENT = https://pig.staging.vault48.org/static/
-EXPOSE = 4000
diff --git a/src/utils/dom.ts b/src/utils/dom.ts
index 43b981ea..700015c3 100644
--- a/src/utils/dom.ts
+++ b/src/utils/dom.ts
@@ -94,8 +94,8 @@ export const getURL = (file: Partial<IFile>, size?: typeof PRESETS[keyof typeof
 };
 
 export const formatText = pipe(
-  formatTextSanitizeYoutube,
   formatTextSanitizeTags,
+  formatTextSanitizeYoutube,
   formatTextClickableUsernames,
   formatTextComments,
   formatTextTodos,
@@ -112,10 +112,12 @@ export const findBlockType = (line: string): ValueOf<typeof COMMENT_BLOCK_TYPES>
 };
 
 export const splitCommentByBlocks = (text: string): ICommentBlock[] =>
-  text.split('\n').map(line => ({
-    type: findBlockType(line),
-    content: line,
-  }));
+  text
+    .split(/(https?:\/\/(?:www\.)(?:youtube\.com|youtu\.be)\/(?:watch)(?:\?v=)[\w\-\&\=]+)/)
+    .map(line => ({
+      type: findBlockType(line),
+      content: line,
+    }));
 
 export const formatCommentText = (author: string, text: string): ICommentBlock[] =>
   text ? splitCommentByBlocks(formatText(text)) : null;