Skip to content

Commit

Permalink
🎉 Client side fix for JSON encoding error in stream
Browse files Browse the repository at this point in the history
  • Loading branch information
ironman5366 committed May 23, 2019
1 parent 78f6bbd commit 198fdbc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions page.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,13 @@ function query_stream(){
$.get({
url: API_URL,
success: function (data){
console.log("Replacing data...");
// Match quotes inside the string
let quoteErrorRegex = new RegExp("[:,]\"([^:,]*\"[^:,]*)\"[:,]", 'g');
let quoteErrors = quoteErrorRegex.exec(data);
if (quoteErrors[1] != null){
data = data.replace(quoteErrors[1], "Invalid Song Title")
}
let parsed_data = JSON.parse(data);
console.log("Fixed stream data");
handle_data(parsed_data);
Expand Down

0 comments on commit 198fdbc

Please sign in to comment.