Merge pull request #5586 from mempool/natsoni/search-bar-seconds

Include optional seconds in search bar date
This commit is contained in:
softsimon 2024-10-13 15:28:49 +09:00 committed by GitHub
commit 5b557b2c12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -313,20 +313,24 @@ export function getRegex(type: RegexType, network?: Network): RegExp {
}
regex += `)`; // End the non-capturing group
break;
// Match a date in the format YYYY-MM-DD (optional: HH:MM)
// Match a date in the format YYYY-MM-DD (optional: HH:MM or HH:MM:SS)
// [Testing Order]: any order is fine
case `date`:
regex += `(?:`; // Start a non-capturing group
regex += `${NUMBER_CHARS}{4}`; // Exactly 4 digits
regex += `[-/]`; // 1 instance of the symbol "-" or "/"
regex += `${NUMBER_CHARS}{1,2}`; // Exactly 4 digits
regex += `${NUMBER_CHARS}{1,2}`; // 1 or 2 digits
regex += `[-/]`; // 1 instance of the symbol "-" or "/"
regex += `${NUMBER_CHARS}{1,2}`; // Exactly 4 digits
regex += `${NUMBER_CHARS}{1,2}`; // 1 or 2 digits
regex += `(?:`; // Start a non-capturing group
regex += ` `; // 1 instance of the symbol " "
regex += `${NUMBER_CHARS}{1,2}`; // Exactly 4 digits
regex += `${NUMBER_CHARS}{1,2}`; // 1 or 2 digits
regex += `:`; // 1 instance of the symbol ":"
regex += `${NUMBER_CHARS}{1,2}`; // Exactly 4 digits
regex += `${NUMBER_CHARS}{1,2}`; // 1 or 2 digits
regex += `(?:`; // Start a non-capturing group for optional seconds
regex += `:`; // 1 instance of the symbol ":"
regex += `${NUMBER_CHARS}{1,2}`; // 1 or 2 digits
regex += `)?`; // End the non-capturing group
regex += `)?`; // End the non-capturing group. This group appears 0 or 1 times
regex += `)`; // End the non-capturing group
break;