Skip to content

Commit 857ac3d

Browse files
committed
fix(pat contentbrowser): Fix physicalPath generation when a Plone site is in a sub folder structure.
1 parent 4f9e5c4 commit 857ac3d

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

src/pat/contentbrowser/src/ContentStore.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,19 @@ export default function (config, pathCache) {
3939
if (!physicalPath.startsWith(rootPath)) {
4040
// The path from the returned items from "vocabularyUrl" are starting
4141
// relative from the Plone Site. So we need to generate the phyiscalPath here.
42-
if (rootPathParts.length === 1) {
43-
physicalPath = rootPath + physicalPath;
44-
} else {
45-
// We also have to merge the rootPath and the clicked path correctly for example:
46-
// rootPath: /Plone/media, clicked path: /media/subfolder
47-
// has to become:
48-
// /Plone/media/subfolder
49-
let pathParts = physicalPath.replace(/^\/+/, '').split("/");
50-
let overlapIdx = rootPathParts.length;
51-
for (let idx = 0; idx < rootPathParts.length; idx++) {
52-
if (rootPathParts[idx] === pathParts[0]) {
53-
overlapIdx = idx;
54-
break;
55-
}
42+
// NOTE: We also have to merge the rootPath and the clicked path correctly for example:
43+
// rootPath: /path/to/plonesite/media, clicked path: /media/subfolder
44+
// has to become:
45+
// /path/to/plonesite/media/subfolder
46+
let pathParts = physicalPath.replace(/^\/+/, '').split("/");
47+
let overlapIdx = 0;
48+
for (overlapIdx; overlapIdx < rootPathParts.length; overlapIdx++) {
49+
if (rootPathParts[overlapIdx] === pathParts[0]) {
50+
break;
5651
}
57-
hideRootPath = "/" + (rootPathParts.filter(it => pathParts.includes(it))).join("/");
58-
physicalPath = "/" + (rootPathParts.slice(1, overlapIdx).concat(pathParts)).join("/");
5952
}
53+
hideRootPath = "/" + (rootPathParts.filter(it => !pathParts.includes(it))).join("/");
54+
physicalPath = "/" + (rootPathParts.slice(0, overlapIdx).concat(pathParts)).join("/");
6055
}
6156

6257
let paths = [];

0 commit comments

Comments
 (0)