From 3c385efc839ad9975596e56d16acebdadffc9bae Mon Sep 17 00:00:00 2001 From: Will Beddow Date: Tue, 28 May 2019 22:32:19 -0500 Subject: [PATCH] :wrench: Use more advanced error correcting regex --- page.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/page.js b/page.js index ded05ce..09b856d 100644 --- a/page.js +++ b/page.js @@ -313,10 +313,10 @@ function query_stream(){ success: function (data){ console.log("Replacing data..."); // Match quotes inside the string - let quoteErrorRegex = new RegExp("[:,]\"([^:,]*\"[^:,]*)\"[:,]", 'g'); + let quoteErrorRegex = new RegExp("\"(?:title|album|artist)\":\"(((?!,\"(album|artist|timestamp)\").)+\"((?!,\"(album|artist|timestamp)\").)*)\",\"(?:album|artist|timestamp)\"", 'g'); let quoteErrors = quoteErrorRegex.exec(data); if (quoteErrors[1] != null){ - data = data.replace(quoteErrors[1], "Invalid Song Title") + data = data.replace(quoteErrors[1], "Invalid Title") } let parsed_data = JSON.parse(data); console.log("Fixed stream data");