From 70a047cd1ca37ad5fbffa622a078c6ec665d6871 Mon Sep 17 00:00:00 2001 From: Bui Date: Sun, 27 Feb 2022 18:23:20 +0000 Subject: [PATCH] improve range parsing --- public/src/js/songselect.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/public/src/js/songselect.js b/public/src/js/songselect.js index fa641d9..410f279 100644 --- a/public/src/js/songselect.js +++ b/public/src/js/songselect.js @@ -2896,9 +2896,12 @@ class SongSelect{ parseRange(string){ var range = string.split("-") if(range.length == 1){ - return {min: parseInt(range[0]), max: parseInt(range[0])} + var min = parseInt(range[0]) || 0 + return min > 0 ? {min: min, max: min} : false } else if(range.length == 2){ - return {min: parseInt(range[0]), max: parseInt(range[1])} + var min = parseInt(range[0]) || 0 + var max = parseInt(range[1]) || 0 + return min > 0 && max > 0 ? {min: min, max: max} : false } } @@ -2918,10 +2921,12 @@ class SongSelect{ case "hard": case "oni": case "ura": - filters[parts[0]] = this.parseRange(parts[1]) + var range = this.parseRange(parts[1]) + if (range) { filters[parts[0]] = range } break case "extreme": - filters.oni = this.parseRange(parts[1]) + var range = this.parseRange(parts[1]) + if (range) { filters.oni = this.parseRange(parts[1]) } break case "clear": case "silver":