1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 23:48:47 +00:00

wiki relative image path

This commit is contained in:
Michael An
2019-06-20 14:40:11 +08:00
parent 58997168f7
commit 08579289d7
3 changed files with 26 additions and 7 deletions

View File

@@ -127,21 +127,23 @@ class WikiMarkdownViewer extends React.Component {
changeInlineNode = (item) => {
if (item.object == 'inline') {
let url;
let url, imagePath;
// change image url
if (item.type == 'image' && isPublicWiki) {
url = item.data.src;
const re = new RegExp(serviceURL + '/lib/' + repoID +'/file.*raw=1');
// different repo
if (!re.test(url)) {
if (re.test(url)) {
// get image path
let index = url.indexOf('/file');
let index2 = url.indexOf('?');
imagePath = url.substring(index + 5, index2);
} else if (/^\.\.\/*/.test(url) || /^\.\/*/.test(url)) {
imagePath = Utils.pathNormalize(this.props.path, url);
} else {
return;
}
// get image path
let index = url.indexOf('/file');
let index2 = url.indexOf('?');
const imagePath = url.substring(index + 5, index2);
// replace url
item.data.src = serviceURL + '/view-image-via-public-wiki/?slug=' + slug + '&path=' + imagePath;
}