check if the subtitle label ends with a number

This commit is contained in:
grunjol
2016-05-13 22:32:43 -03:00
parent ffb7183f51
commit 7d64c7e308

View File

@@ -612,9 +612,10 @@ function addSubtitle (file) {
state.playing.subtitles.tracks.forEach(function (trackItem) { state.playing.subtitles.tracks.forEach(function (trackItem) {
trackItem.selected = false trackItem.selected = false
if (trackItem.label === track.label) { if (trackItem.label === track.label) {
track.label = Number.isNaN(track.label.slice(-1)) var labelParts = /([^\d]+)(\d+)$/.exec(track.label)
? track.label + ' 2' track.label = labelParts
: track.label.slice(0, -1) + (parseInt(track.label.slice(-1)) + 1) ? labelParts[1] + (parseInt(labelParts[2]) + 1)
: track.label + ' 2'
} }
}) })
state.playing.subtitles.change = track.label state.playing.subtitles.change = track.label