From f3aba3c4dffe192d7fa63c022399684cf3377ccd Mon Sep 17 00:00:00 2001 From: Chuck Dries Date: Sun, 10 Jul 2022 17:30:51 -0700 Subject: [PATCH] fix build crash? --- src/utils.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/utils.js b/src/utils.js index ae858ec..ea4da09 100644 --- a/src/utils.js +++ b/src/utils.js @@ -80,11 +80,14 @@ export const getShutterFractionFromExposureTime = (exposureTime) => { return `${numerator}/${denominator}`; }; -export const getGalleryPageUrl = ( - { keyword, sortKey }, - hash -) => { - const url = new URL(`${window?.location.origin ?? 'https://chuckdries.com'}/photogallery/`); +export const getGalleryPageUrl = ({ keyword, sortKey }, hash) => { + const url = new URL( + `${ + typeof window !== "undefined" + ? window.location.origin + : "https://chuckdries.com" + }/photogallery/` + ); if (keyword !== undefined) { if (keyword === null) { url.searchParams.delete("filter"); @@ -102,5 +105,5 @@ export const getGalleryPageUrl = ( if (hash) { url.hash = hash; } - return url.href.toString().replace(url.origin, ''); + return url.href.toString().replace(url.origin, ""); };