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