yusuketk %!s(int64=5) %!d(string=hai) anos
pai
achega
2e7d658f57
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      src/client/js/components/PageEditor/LinkEditModal.jsx

+ 6 - 2
src/client/js/components/PageEditor/LinkEditModal.jsx

@@ -72,9 +72,13 @@ class LinkEditModal extends React.PureComponent {
       type = Linker.types.markdownLink;
     }
 
-    const isUseRelativePath = link.startsWith('.');
+    const url = new URL(link, window.location.origin);
+    const isUseRelativePath = url.origin !== window.location && !link.startsWith('/') && link !== '';
     if (isUseRelativePath) {
-      link = path.resolve(pageContainer.state.path, link);
+      const pagePath = pageContainer.state.path;
+      // rootPaths of md link and pukiwiki link are different
+      const rootPath = type === Linker.types.markdownLink ? path.dirname(pagePath) : pagePath;
+      link = path.resolve(rootPath, link);
     }
 
     this.setState({