Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use !== -1 to check for a string's existence #1372

Merged
merged 1 commit into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/pi-hole/js/db_lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function updateTopClientsChart() {
data.top_sources[escapeHtml(client)] = data.top_sources[client];
}

if (client.indexOf("|") > -1) {
if (client.indexOf("|") !== -1) {
var idx = client.indexOf("|");
clientname = client.substr(0, idx);
} else {
Expand Down
6 changes: 3 additions & 3 deletions scripts/pi-hole/js/db_queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ function add(domain, list) {
data: { domain: domain, list: list, token: token },
success: function (response) {
if (
response.indexOf("not a valid argument") >= 0 ||
response.indexOf("is not a valid domain") >= 0
response.indexOf("not a valid argument") !== -1 ||
response.indexOf("is not a valid domain") !== -1
) {
alFailure.show();
err.html(response);
Expand Down Expand Up @@ -136,7 +136,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 occurred while loading the data: Connection refused. Is FTL running?");
} else {
alert("An unknown error occurred while loading the data.\n" + xhr.responseText);
Expand Down
6 changes: 3 additions & 3 deletions scripts/pi-hole/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ function updateForwardDestinationsPie() {

// Collect values and colors
$.each(data.forward_destinations, function (key, value) {
if (key.indexOf("|") > -1) {
if (key.indexOf("|") !== -1) {
key = key.substr(0, key.indexOf("|"));
}

Expand Down Expand Up @@ -559,7 +559,7 @@ function updateTopClientsChart() {
}

client = escapeHtml(client);
if (client.indexOf("|") > -1) {
if (client.indexOf("|") !== -1) {
idx = client.indexOf("|");
clientname = client.substr(0, idx);
clientip = client.substr(idx + 1, client.length - idx);
Expand Down Expand Up @@ -605,7 +605,7 @@ function updateTopClientsChart() {
}

client = escapeHtml(client);
if (client.indexOf("|") > -1) {
if (client.indexOf("|") !== -1) {
idx = client.indexOf("|");
clientname = client.substr(0, idx);
clientip = client.substr(idx + 1, client.length - idx);
Expand Down
2 changes: 1 addition & 1 deletion scripts/pi-hole/js/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var MAXIPDISPLAY = 3;
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);
Expand Down
8 changes: 4 additions & 4 deletions scripts/pi-hole/js/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down