From 746a6231fadc02af789d24d4898d86e114f1ed22 Mon Sep 17 00:00:00 2001 From: DesertCookie Date: Thu, 10 Sep 2020 09:22:58 +0200 Subject: [PATCH] Added number check to sorting and parseInt radix Introduced changes suggested by thornbill. --- src/controllers/itemDetails/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/itemDetails/index.js b/src/controllers/itemDetails/index.js index 1b07aef332..64b4f2f777 100644 --- a/src/controllers/itemDetails/index.js +++ b/src/controllers/itemDetails/index.js @@ -172,10 +172,10 @@ function renderTrackSelections(page, instance, item, forceReload) { var resolutionNames = []; var sourceNames = []; mediaSources.forEach(function (v) { - (v.Name.endsWith('p') || v.Name.endsWith('i')) ? resolutionNames.push(v) : sourceNames.push(v); + ((v.Name.endsWith('p') || v.Name.endsWith('i'))) && !Number.isNaN(parseInt(v.Name, 10) ? resolutionNames.push(v) : sourceNames.push(v); }); - resolutionNames.sort((a, b) => parseInt(b.Name) - parseInt(a.Name)); + resolutionNames.sort((a, b) => parseInt(b.Name, 10) - parseInt(a.Name, 10)); sourceNames.sort(function(a, b) { var nameA = a.Name.toUpperCase(); var nameB = b.Name.toUpperCase();