keigo-h 3 лет назад
Родитель
Сommit
d89710a1ea
1 измененных файлов с 7 добавлено и 3 удалено
  1. 7 3
      packages/app/src/client/services/ShowPageAccessories.tsx

+ 7 - 3
packages/app/src/client/services/ShowPageAccessories.tsx

@@ -6,10 +6,10 @@ function getURLQueryParamValue(key: string): string | null {
 // window.location.href is page URL;
   const queryStr: URLSearchParams = new URL(window.location.href).searchParams;
   if (queryStr === null) {
-    return '';
+    return null;
   }
   if (queryStr.get(key) === null) {
-    return '';
+    return null;
   }
   return queryStr.get(key);
 }
@@ -17,7 +17,11 @@ function getURLQueryParamValue(key: string): string | null {
 const ShowPageAccessoriesModal = (): JSX.Element => {
   const { open: openPageAccessories } = usePageAccessoriesModal();
   useEffect(() => {
-    if (getURLQueryParamValue('compare')!.split('...').length > 1) {
+    const pageIdParams = getURLQueryParamValue('compare');
+    if (pageIdParams === null) {
+      return;
+    }
+    if (pageIdParams.split('...').length > 1) {
       openPageAccessories(PageAccessoriesModalContents.PageHistory);
     }
     // eslint-disable-next-line react-hooks/exhaustive-deps