From 3cbb8d9b257b400af5dab99f88f37ad5dde6ff8d Mon Sep 17 00:00:00 2001 From: memorydream <34763046+memorydream@users.noreply.github.com> Date: Mon, 17 Jan 2022 21:12:40 +0800 Subject: [PATCH] fix: wrong trim all white space lyric (#1233) --- src/utils/lyrics.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/lyrics.js b/src/utils/lyrics.js index aa7f23e..394b73c 100644 --- a/src/utils/lyrics.js +++ b/src/utils/lyrics.js @@ -28,7 +28,7 @@ export function parseLyric(lrc) { lrcObj.push({ time: time, rawTime: timeRegExpArr[0], - content: content.trim(), + content: trimContent(content), }); } } @@ -36,3 +36,8 @@ export function parseLyric(lrc) { lrcObj.sort((a, b) => a.time - b.time); return lrcObj; } + +function trimContent(content) { + let t = content.trim(); + return t.length < 1 ? content : t; +}