mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-04 10:26:02 -05:00
[web] Use named capture groups
This commit is contained in:
parent
7826b36634
commit
ea947df50a
@ -32,7 +32,6 @@ export default [
|
||||
'no-undef': 'off',
|
||||
'no-unused-vars': ['error', { args: 'none', caughtErrors: 'none' }],
|
||||
'one-var': 'off',
|
||||
'prefer-named-capture-group': 'off',
|
||||
'sort-keys': 'off',
|
||||
'vue/html-self-closing': 'off',
|
||||
'vue/max-attributes-per-line': 'off',
|
||||
|
@ -55,13 +55,15 @@ export default {
|
||||
const parsed = []
|
||||
if (raw) {
|
||||
// Parse the lyrics
|
||||
const regex = /(\[(\d+):(\d+)(?:\.\d+)?\] ?)?(.*)/u
|
||||
raw.split('\n').forEach((item, index) => {
|
||||
const matches = regex.exec(item)
|
||||
if (matches && matches[4]) {
|
||||
const regex =
|
||||
/\[(?<minutes>\d+):(?<seconds>\d+)(?:\.(?<hundredths>\d+))?\] ?(?<text>.*)/u
|
||||
raw.split('\n').forEach((item) => {
|
||||
const { text, minutes, seconds, hundredths } = regex.exec(line).groups
|
||||
if (text) {
|
||||
const verse = {
|
||||
text: matches[4],
|
||||
time: matches[2] * 60 + Number(matches[3])
|
||||
text,
|
||||
time:
|
||||
minutes * 60 + Number(seconds) + Number(`.${hundredths || 0}`)
|
||||
}
|
||||
parsed.push(verse)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user