settings: Check if xhr response text include ':' or not.

We join extra text message for notification and xhr response text by ':'.
Before joining, check if xhr response text already include ':', to
prevent notification with more than one ':'.
This commit is contained in:
YJDave 2017-12-28 18:55:23 +05:30 committed by showell
parent c06028159e
commit dd406e87e9

View File

@ -44,7 +44,12 @@ exports.error = function (response, xhr, status_box, type) {
if (xhr && xhr.status.toString().charAt(0) === "4") {
// Only display the error response for 4XX, where we've crafted
// a nice response.
response += ": " + escape(JSON.parse(xhr.responseText).msg);
var response_text = escape(JSON.parse(xhr.responseText).msg);
if (response_text.indexOf(':') > -1) {
response = response_text;
} else {
response += ": " + response_text;
}
}
exports.message(response, status_box, 'alert-error', type);