luci-base: handle application/json replies with charset specification
On my router, the response header Content-Type is `application/json; charset=UTF-8` instead of `application/json`, so almost every feature is broken. Fixes: #2851 Suggested-by: zhanhb <6323014+zhanhb@users.noreply.github.com> [reword commit subject] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
a388be0f28
commit
28ab21dd8d
1 changed files with 1 additions and 1 deletions
|
@ -88,7 +88,7 @@ XHR = function()
|
|||
{
|
||||
if (xhr.readyState == 4) {
|
||||
var json = null;
|
||||
if (xhr.getResponseHeader("Content-Type") == "application/json") {
|
||||
if (/^application\/json\b/.test(xhr.getResponseHeader("Content-Type"))) {
|
||||
try { json = JSON.parse(xhr.responseText); }
|
||||
catch(e) { json = null; }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue