Merge pull request #1372 from pi-hole/indexOf

Always use `!== -1` to check for a string's existence
This commit is contained in:
DL6ER
2020-05-25 20:42:02 +02:00
committed by GitHub
5 changed files with 12 additions and 12 deletions

View File

@@ -45,9 +45,9 @@ function add(domain, list) {
success: function (response) {
alProcessing.hide();
if (
response.indexOf("not a valid argument") >= 0 ||
response.indexOf("is not a valid domain") >= 0 ||
response.indexOf("Wrong token") >= 0
response.indexOf("not a valid argument") !== -1 ||
response.indexOf("is not a valid domain") !== -1 ||
response.indexOf("Wrong token") !== -1
) {
// Failure
alNetworkErr.hide();
@@ -90,7 +90,7 @@ function add(domain, list) {
function handleAjaxError(xhr, textStatus) {
if (textStatus === "timeout") {
alert("The server took too long to send the data.");
} else if (xhr.responseText.indexOf("Connection refused") >= 0) {
} else if (xhr.responseText.indexOf("Connection refused") !== -1) {
alert("An error occured while loading the data: Connection refused. Is FTL running?");
} else {
alert("An unknown error occured while loading the data.\n" + xhr.responseText);