From 76fee917ea1a8bd3bfce8db1ad46169219f51c76 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 2 Oct 2017 17:06:15 -0600 Subject: [PATCH] use lastIndexOf --- bin/dig.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/dig.js b/bin/dig.js index 925dbc5..19203a5 100755 --- a/bin/dig.js +++ b/bin/dig.js @@ -199,7 +199,7 @@ cli.main(function (args, cli) { } packet.question.forEach(function (q) { - // if (-1 === q.name.indexOf(cli.casedQuery)) + // if (-1 === q.name.lastIndexOf(cli.casedQuery)) if (q.name !== cli.casedQuery) { fail0x20 = q.name; } @@ -209,8 +209,8 @@ cli.main(function (args, cli) { [ 'question', 'answer', 'authority', 'additional' ].forEach(function (group) { (packet[group]||[]).forEach(function (a) { var an = a.name; - var i = cli.query.toLowerCase().indexOf(a.name.toLowerCase()); // answer is something like ExAMPle.cOM and query was wWw.ExAMPle.cOM - var j = a.name.toLowerCase().indexOf(cli.query.toLowerCase()); // answer is something like www.ExAMPle.cOM and query was ExAMPle.cOM + var i = cli.query.toLowerCase().lastIndexOf(a.name.toLowerCase()); // answer is something like ExAMPle.cOM and query was wWw.ExAMPle.cOM + var j = a.name.toLowerCase().lastIndexOf(cli.query.toLowerCase()); // answer is something like www.ExAMPle.cOM and query was ExAMPle.cOM // it's important to note that these should only relpace changes in casing that we expected // any abnormalities should be left intact to go "huh?" about