فهرست منبع

refactor for replacing url

yohei0125 3 سال پیش
والد
کامیت
14e3d5d4d9
1فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 6 4
      packages/app/src/components/NotFoundPage.tsx

+ 6 - 4
packages/app/src/components/NotFoundPage.tsx

@@ -27,11 +27,13 @@ const NotFoundPage = (): JSX.Element => {
 
   // replace url in address bar with path when accessing empty page by permalink
   useEffect(() => {
-    const isEmptyPage = pageId != null; // Todo: should be improved. https://redmine.weseek.co.jp/issues/98152
-    const isPathExist = path != null;
-    const isPathLink = notFoundTargetPathOrId?.includes('/');
+    if (path == null) {
+      return;
+    }
 
-    if (isEmptyPage && isPathExist && !isPathLink) {
+    const isEmptyPage = pageId != null; // Todo: should be improved. https://redmine.weseek.co.jp/issues/98152
+    const isPermalink = !notFoundTargetPathOrId?.includes('/');
+    if (isEmptyPage && isPermalink) {
       // The (as string) below is a workaround for the case. See the link. (Fixed in typescript version 4.4)
       // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-4.html#control-flow-analysis-of-aliased-conditions-and-discriminants
       replaceURLHistory(path as string);