From ece8485df53c606944235989c22277dfafc401c4 Mon Sep 17 00:00:00 2001 From: OnkarRuikar <87750369+OnkarRuikar@users.noreply.github.com> Date: Sun, 29 Sep 2024 09:02:48 +0530 Subject: [PATCH] use toLowerCase for comparisons --- scripts/sort_and_unique_file_lines.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/sort_and_unique_file_lines.js b/scripts/sort_and_unique_file_lines.js index ca103257bb41f58..90da8ada80e1c75 100644 --- a/scripts/sort_and_unique_file_lines.js +++ b/scripts/sort_and_unique_file_lines.js @@ -12,15 +12,12 @@ if (!fs.existsSync(filePath)) { process.exit(1); } -function equalsIgnoreCase(string1, string2) { - return new RegExp(`^${string1}$`, "gi").test(string2); -} - +const equalsIgnoreCase = (a, b) => a?.toLowerCase() === b?.toLowerCase(); const uniq = []; const content = fs.readFileSync(filePath, "utf-8"); const lines = content.split("\n").sort((a, b) => { - a = a.toUpperCase(); - b = b.toUpperCase(); + a = a.toLowerCase(); + b = b.toLowerCase(); return a < b ? -1 : a > b ? 1 : 0; });