Skip to content

Commit 143f71a

Browse files
Update src/utils/Url.js
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent fdf0026 commit 143f71a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/utils/Url.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,18 @@ export default {
8787
}
8888
// if pathname is undefined, meaning a docId/volume (e.g :primary:)
8989
// has not been detected, so no newDocId's ":" will be added.
90-
if(!pathname) return `${contentUri.rootUri}::${root}${newDocId.startsWith("/") ? newDocId.slice(1) : newDocId}${query}`
90+
if(!pathname) {
91+
// Ensure proper path separator between root and newDocId
92+
let separator = '';
93+
if (root.endsWith('/') && newDocId.startsWith('/')) {
94+
// Both have separator, strip one from newDocId
95+
newDocId = newDocId.slice(1);
96+
} else if (!root.endsWith('/') && !newDocId.startsWith('/')) {
97+
// Neither has separator, add one
98+
separator = '/';
99+
}
100+
return `${contentUri.rootUri}::${root}${separator}${newDocId}${query}`;
101+
}
91102
return `${contentUri.rootUri}::${root}${newDocId}${query}`;
92103
}
93104
return `${contentUri.rootUri}::${root}:${newDocId}${query}`;

0 commit comments

Comments
 (0)