mirror of
https://github.com/clarencechaan/ufc-cal.git
synced 2026-10-19 00:38:30 -07:00
Throw error if fighter name cannot be retrieved
This commit is contained in:
1 parent
d09cc09071
commit
997aee6171
1 file changed
+7
-5
+7
-5
@@ -91,11 +91,13 @@ function convertLiToStr(li: HTMLElement) {
|
||||
?.textContent?.replaceAll("\n", "")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
const ranks = [
|
||||
...li.querySelectorAll(
|
||||
if (!red || !blue) throw new Error("Failed to retrieve fighter names");
|
||||
|
||||
const ranks = li
|
||||
.querySelectorAll(
|
||||
".c-listing-fight__ranks-row .js-listing-fight__corner-rank span"
|
||||
),
|
||||
].map((rank) => rank?.textContent);
|
||||
)
|
||||
.map((rank) => rank?.textContent);
|
||||
|
||||
const redRankStr = ranks[0] ? ` (${ranks[0]})` : "";
|
||||
const blueRankStr = ranks[1] ? ` (${ranks[1]})` : "";
|
||||
@@ -151,7 +153,7 @@ async function getDetailsFromEventLink(url: URL) {
|
||||
const mainCardElements = root.querySelectorAll(
|
||||
"#main-card .l-listing__item"
|
||||
);
|
||||
// Check if main card & prelims have been announced
|
||||
// Check if main card and prelims have been announced
|
||||
if (mainCardElements.length) {
|
||||
// Main card has been announced, extract prelims
|
||||
const prelimsElements = root.querySelectorAll(
|
||||
|
||||
Reference in new issue
Block a user