From 82e92a6b6759e21d1a95fab89637639222796224 Mon Sep 17 00:00:00 2001 From: LeeWannacott Date: Fri, 12 May 2023 00:26:03 +1200 Subject: [PATCH] HotFix: stop accidental inferring that a semantic version number is a date. --- public/table-sort.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/table-sort.js b/public/table-sort.js index 9e6e00b..95f4b2a 100644 --- a/public/table-sort.js +++ b/public/table-sort.js @@ -70,7 +70,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { for (let [columnIndex, th] of tableHeadHeaders.entries()) { const regexMinutesAndSeconds = /^(\d+h)?\s?(\d+m)?\s?(\d+s)?$/i; const regexFileSizeSort = /^([.0-9]+)\s?(B|KB|KiB|MB|MiB|GB|GiB|TB|TiB)/i; - const regexDates = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + // Doesn't infer dates with delimiter "."; as could capture semantic version numbers. + const regexDates = /^(\d\d?)[/-](\d\d?)[/-]((\d\d)?\d\d)$/; let runtimeSortCounter = 0, fileSizeSortCounter = 0, datesSortCounter = 0; @@ -230,9 +231,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { try { for (let [i, tr] of tableRows.entries()) { let columnOfTd; - const regexDate = /^(\d\d?)[./-](\d\d?)[./-]((\d\d)?\d\d)$/; + const regexDates = /^(\d\d?)[./-](\d\d?)[./-]((\d\d)?\d\d)$/; columnOfTd = tr.querySelectorAll("td").item(columnIndex).textContent; - let match = columnOfTd.match(regexDate); + let match = columnOfTd.match(regexDates); let [years, days, months] = [0, 0, 0]; let numberToSort = columnOfTd; if (match) {