diff --git a/frontend/src/App.js b/frontend/src/App.js index d4bf6c3888..8e610d9eb3 100755 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -96,7 +96,7 @@ class EditorUtilities { url = serviceUrl + "/lib/" + repoID + "/file" + encodeURIComponent(fileNode.path()); } } else { - url = serviceUrl + "/#common/lib/" + repoID + "/" + encodeURIComponent(fileNode.path()); + url = serviceUrl + "/#common/lib/" + repoID + encodeURIComponent(fileNode.path()); } return url; } @@ -108,7 +108,7 @@ class EditorUtilities { isInternalDirLink(url) { - var re = new RegExp(serviceUrl + "/#[a-z\-]*?/lib/" + "[0-9a-f\-]{36}/.*"); + var re = new RegExp(serviceUrl + "/#[a-z\-]*?/lib/" + "[0-9a-f\-]{36}.*"); return re.test(url); } diff --git a/frontend/src/wiki.js b/frontend/src/wiki.js index 81faa93653..9f07990c37 100644 --- a/frontend/src/wiki.js +++ b/frontend/src/wiki.js @@ -98,6 +98,9 @@ class Wiki extends Component { if (this.isInternalMarkdownLink(url)) { let path = this.getPathFromInternalMarkdownLink(url); this.initMainPanelData(path); + } else if (this.isInternalDirLink(url)) { + let path = this.getPathFromInternalDirLink(url); + this.initWikiData(path); } else { window.location.href = url; } @@ -424,6 +427,11 @@ class Wiki extends Component { return re.test(url); } + isInternalDirLink(url) { + var re = new RegExp(serviceUrl + '/#[a-z\-]*?/lib/' + repoID + '/.*'); + return re.test(url); + } + getPathFromInternalMarkdownLink(url) { var re = new RegExp(serviceUrl + '/lib/' + repoID + '/file' + "(.*\.md)"); var array = re.exec(url); @@ -431,6 +439,22 @@ class Wiki extends Component { return path; } + getPathFromInternalDirLink(url) { + var re = new RegExp(serviceUrl + '/#[a-z\-]*?/lib/' + repoID + "(/.*)"); + var array = re.exec(url); + var path = decodeURIComponent(array[1]); + + var dirPath = path.substring(1); + var re = new RegExp("(^/.*)"); + if (re.test(dirPath)) { + path = dirPath; + } else { + path = '/' + dirPath + } + + return path; + } + render() { return (