[bugfix]: support final lyric with no newline (#240)

This commit is contained in:
Kendall Garner 2023-09-10 22:07:21 +00:00 committed by GitHub
parent 4e5e3bc9a1
commit c90a56811d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,11 +18,11 @@ const lyricsIpc = isElectron() ? window.electron.lyrics : null;
// Match LRC lyrics format by https://github.com/ustbhuangyi/lyric-parser
// [mm:ss.SSS] text
const timeExp = /\[(\d{2,}):(\d{2})(?:\.(\d{2,3}))?]([^\n]+)\n/g;
const timeExp = /\[(\d{2,}):(\d{2})(?:\.(\d{2,3}))?]([^\n]+)(\n|$)/g;
// Match karaoke lyrics format returned by NetEase
// [SSS,???] text
const alternateTimeExp = /\[(\d*),(\d*)]([^\n]+)\n/g;
const alternateTimeExp = /\[(\d*),(\d*)]([^\n]+)(\n|$)/g;
const formatLyrics = (lyrics: string) => {
const synchronizedLines = lyrics.matchAll(timeExp);