Skip to content

Commit

Permalink
🔧 Use more advanced error correcting regex
Browse files Browse the repository at this point in the history
  • Loading branch information
ironman5366 committed May 29, 2019
1 parent e435e64 commit 3c385ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 3c385ef

Please sign in to comment.