fix ItemPage safeImageUrl loading bug

When you navigated directly to ItemPage, the new `safeImageUrl` function would crash during the loading state, because it was trying to safe-ify `undefined`.

Now, I've just made `safeImageUrl` more resilient to that particular kind of unexpected input, by passing through null-y values without change.
This commit is contained in:
Emi Matchu 2020-10-22 20:53:21 -07:00
parent dd4f34ef73
commit d2671d0fa6

View file

@ -65,6 +65,10 @@ export function Heading2({ children, ...props }) {
* safeImageUrl returns an HTTPS-safe image URL for Neopets assets!
*/
export function safeImageUrl(urlString) {
if (urlString == null) {
return urlString;
}
const url = new URL(urlString);
if (url.origin === "http://images.neopets.com") {