Ver código fonte

fix page path

ryohek 5 anos atrás
pai
commit
72f0c8ba06
1 arquivos alterados com 16 adições e 8 exclusões
  1. 16 8
      src/client/js/components/Page/CopyDropdown.jsx

+ 16 - 8
src/client/js/components/Page/CopyDropdown.jsx

@@ -54,8 +54,11 @@ class CopyDropdown extends React.Component {
   }
 
   generatePagePathWithParams() {
-    const { pagePath, pageId, isShareLinkMode } = this.props;
-    if (isShareLinkMode) {
+    const { pagePath, pageId } = this.props;
+    if (pageId == null) {
+      return null;
+    }
+    if (pagePath == null) {
       return decodeURI(`/share/${pageId}`);
     }
     return decodeURI(`${pagePath}${this.uriParams}`);
@@ -69,20 +72,25 @@ class CopyDropdown extends React.Component {
   generatePermalink() {
     const { pageId, isShareLinkMode } = this.props;
 
-    if (isShareLinkMode) {
-      return decodeURI(`${origin}/share/${pageId}`);
-    }
     if (pageId == null) {
       return null;
     }
+    if (isShareLinkMode) {
+      return decodeURI(`${this.generatePagePathUrl()}`);
+    }
 
     return decodeURI(`${origin}/${pageId}${this.uriParams}`);
   }
 
   generateMarkdownLink() {
-    const { pageId, pagePath, isShareLinkMode } = this.props;
-
-    const label = isShareLinkMode ? decodeURI(pageId) : decodeURI(`${pagePath}${this.uriParams}`);
+    const { pagePath } = this.props;
+    let label;
+    if (pagePath == null) {
+      label = this.generatePagePathWithParams();
+    }
+    else {
+      label = decodeURI(`${pagePath}${this.uriParams}`);
+    }
     const permalink = this.generatePermalink();
 
     return `[${label}](${permalink})`;