« get me outta code hell

data: looser commentary date parsing + clearer regex explanation - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-18 19:30:27 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-18 19:30:27 -0400
commit522c982bf0b5a0bd39512eb56a9d0d8d8feea44e (patch)
treeee78f828525a3959130c14eb49ab95c337dfaa39 /src
parent4b7da4c1f8c359e5c82c4cc5e0cfb78f8204850f (diff)
data: looser commentary date parsing + clearer regex explanation
Diffstat (limited to 'src')
-rw-r--r--src/util/wiki-data.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js
index 8a6d4345..09b3623e 100644
--- a/src/util/wiki-data.js
+++ b/src/util/wiki-data.js
@@ -641,8 +641,10 @@ export function sortFlashesChronologically(data, {
 //
 //   * "25 December 2019" - one or two number digits, followed by any text,
 //     followed by four number digits
-//   * "12/25/2019" - one or two number digits, a slash, one or two number
-//     digits, a slash, and two to four number digits
+//   * "December 25, 2019" - one all-letters word, a space, one or two number
+//     digits, a comma, and four number digits
+//   * "12/25/2019" etc - three sets of one to four number digits, separated
+//     by slashes (only valid formats are MM/DD/YYYY and YYYY/MM/DD)
 //
 // Capturing group "artistReference" is all the characters between <i> and </i>
 // (apart from the pipe and "artistDisplayText" text, if present), and is either
@@ -652,7 +654,7 @@ export function sortFlashesChronologically(data, {
 // out of the original string based on the indices matched using this.
 //
 export const commentaryRegex =
-  /^<i>(?<artistReferences>.+?)(?:\|(?<artistDisplayText>.+))?:<\/i>(?: \((?<annotation>(?:.*?(?=,|\)$))*?)(?:,? ?(?<date>[a-zA-Z]+ [0-9]{1,2}, [0-9]{4,4}|[0-9]{1,2} [^,]*[0-9]{4,4}|[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{2,4}))?\))?$/gm;
+  /^<i>(?<artistReferences>.+?)(?:\|(?<artistDisplayText>.+))?:<\/i>(?: \((?<annotation>(?:.*?(?=,|\)$))*?)(?:,? ?(?<date>[a-zA-Z]+ [0-9]{1,2}, [0-9]{4,4}|[0-9]{1,2} [^,]*[0-9]{4,4}|[0-9]{1,4}\/[0-9]{1,4}\/[0-9]{1,4}))?\))?$/gm;
 
 export function filterAlbumsByCommentary(albums) {
   return albums