fix: robust coaster matching + dark carnival color scheme
Matching fixes: - normalize() now strips all non-word/non-space chars via [^\w\s] instead of a hand-rolled list, catching !, curly apostrophe (U+2019), and any future edge cases - Add isCoaster() helper with prefix matching (min 5 chars) to handle subtitle mismatches in either direction (e.g. "Apocalypse" vs "Apocalypse the Ride", "The New Revolution - Classic" vs "New Revolution") - Fix top-level rides loop which still used coasterNames.has(normalize()) instead of isCoaster() — this was the recurring bug causing top-level rides to miss UI: - Dark neutral base (#111) replacing cold navy and muddy purple - Neon accent palette: hot pink, electric green, vivid yellow, cyan - Park page max-width 960→1280px, calendar cells 72→96px tall - Scrollbar accent matches theme Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -67,9 +67,9 @@ export function areCoastersStale(entry: ParkMeta): boolean {
|
||||
*/
|
||||
export function normalizeRideName(name: string): string {
|
||||
return name
|
||||
.replace(/[™®©]/g, "")
|
||||
.replace(/[\u2122\u00ae\u00a9™®©]/g, "")
|
||||
.replace(/^the\s+/i, "")
|
||||
.replace(/[-:'".]/g, " ")
|
||||
.replace(/[^\w\s]/g, " ")
|
||||
.replace(/\s+/g, " ")
|
||||
.toLowerCase()
|
||||
.trim();
|
||||
|
||||
@@ -11,18 +11,44 @@ const BASE = "https://queue-times.com/parks";
|
||||
|
||||
/**
|
||||
* Normalize a ride name for fuzzy matching between Queue-Times and RCDB.
|
||||
* Strips trademark symbols, leading "THE ", and punctuation before comparing.
|
||||
*
|
||||
* - Strips trademark/copyright symbols (™ ® © and Unicode variants)
|
||||
* - Strips leading "THE " prefix
|
||||
* - Replaces ALL non-word, non-space characters with a space
|
||||
* (handles !, -, :, ', ' U+2019, ", and any other punctuation)
|
||||
* - Collapses whitespace, lowercases, trims
|
||||
*/
|
||||
function normalize(name: string): string {
|
||||
return name
|
||||
.replace(/[™®©]/g, "")
|
||||
.replace(/[\u2122\u00ae\u00a9™®©]/g, "")
|
||||
.replace(/^the\s+/i, "")
|
||||
.replace(/[-:'".]/g, " ")
|
||||
.replace(/[^\w\s]/g, " ")
|
||||
.replace(/\s+/g, " ")
|
||||
.toLowerCase()
|
||||
.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Queue-Times ride name matches any coaster in the RCDB set.
|
||||
*
|
||||
* Exact normalized match covers most cases. Prefix matching handles cases
|
||||
* where one source drops or adds a subtitle:
|
||||
* "Apocalypse" (QT) vs "Apocalypse the Ride" (RCDB)
|
||||
* "The New Revolution - Classic" (QT) vs "New Revolution" (RCDB)
|
||||
*
|
||||
* Minimum 5 chars on the shorter side prevents accidental short matches.
|
||||
*/
|
||||
function isCoaster(name: string, coasterSet: Set<string>): boolean {
|
||||
const norm = normalize(name);
|
||||
if (coasterSet.has(norm)) return true;
|
||||
for (const c of coasterSet) {
|
||||
const shorter = norm.length <= c.length ? norm : c;
|
||||
const longer = norm.length <= c.length ? c : norm;
|
||||
if (shorter.length >= 5 && longer.startsWith(shorter)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const HEADERS = {
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
|
||||
@@ -105,7 +131,7 @@ export async function fetchLiveRides(
|
||||
isOpen: r.is_open,
|
||||
waitMinutes: r.wait_time ?? 0,
|
||||
lastUpdated: r.last_updated,
|
||||
isCoaster: coasterNames ? coasterNames.has(normalize(r.name)) : false,
|
||||
isCoaster: coasterNames ? isCoaster(r.name, coasterNames) : false,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -118,7 +144,7 @@ export async function fetchLiveRides(
|
||||
isOpen: r.is_open,
|
||||
waitMinutes: r.wait_time ?? 0,
|
||||
lastUpdated: r.last_updated,
|
||||
isCoaster: coasterNames ? coasterNames.has(normalize(r.name)) : false,
|
||||
isCoaster: coasterNames ? isCoaster(r.name, coasterNames) : false,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user