explorer: prevent large slot number input stemming from hex strings (#15438)

* explorer: prevent large slot number input stemming from hex strings

* explorer: support IE11
This commit is contained in:
Josh 2021-02-19 09:20:03 -08:00 committed by GitHub
parent 524da78e43
commit 5548e599fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -3,13 +3,17 @@ import React from "react";
import { ErrorCard } from "components/common/ErrorCard";
import { BlockOverviewCard } from "components/block/BlockOverviewCard";
// IE11 doesn't support Number.MAX_SAFE_INTEGER
const MAX_SAFE_INTEGER = 9007199254740991;
type Props = { slot: string };
export function BlockDetailsPage({ slot }: Props) {
const slotNumber = Number(slot);
let output = <ErrorCard text={`Block ${slot} is not valid`} />;
if (!isNaN(Number(slot))) {
output = <BlockOverviewCard slot={Number(slot)} />;
if (!isNaN(slotNumber) && slotNumber < MAX_SAFE_INTEGER) {
output = <BlockOverviewCard slot={slotNumber} />;
}
return (