Skip to content

Commit a8d8b1a

Browse files
committed
Fix compare page when no query params supplied
1 parent b9fb995 commit a8d8b1a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

site/static/compare.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,8 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
376376
<script src="shared.js"></script>
377377
<script>
378378
function findQueryParam(name) {
379-
if (!window.location.search) {
380-
return null;
381-
}
382-
let urlParams = window.location.search.substring(1).split("&").map(x => x.split("="));
383-
let pair = urlParams.find(x => x[0] === name)
379+
let urlParams = window.location.search?.substring(1).split("&").map(x => x.split("="));
380+
let pair = urlParams?.find(x => x[0] === name)
384381
if (pair) {
385382
return unescape(pair[1]);
386383
}
@@ -436,7 +433,10 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
436433
for (let d of data.a.data[name]) {
437434
const key = d[0];
438435
const datumA = d[1];
439-
const datumB = data.b.data[name].find(x => x[0] == key)[1];
436+
const datumB = data.b.data[name]?.find(x => x[0] == key)?.[1];
437+
if (!datumB) {
438+
continue;
439+
}
440440
let percent = (100 * (datumB - datumA) / datumA).toFixed(1);
441441
if (percent === "-0.0") {
442442
percent = "0.0";
@@ -445,7 +445,7 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
445445
let isDodgy = false;
446446
if (data.variance) {
447447
let variance = data.variance[name + "-" + key];
448-
isDodgy = !!(variance && variance.description && variance.description.type != "Normal");
448+
isDodgy = (variance?.description?.type ?? "Normal") != "Normal";
449449
}
450450
if (shouldShowBuild(key)) {
451451
variants.push({

0 commit comments

Comments
 (0)