Skip to content

Commit 57e7ee1

Browse files
fix(Url): root/docId separator in Url util
Move pathname handling into the correct branch and ensure a ':' is inserted between root and newDocId when appropriate
1 parent 9eb0640 commit 57e7ee1

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/utils/Url.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,23 @@ export default {
8585
} else if (!rootCondition === !newDocIdCondition) {
8686
root += "/";
8787
}
88-
// if pathname is undefined, meaning a docId/volume (e.g :primary:)
89-
// has not been detected, so no newDocId's ":" will be added.
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-
}
10288
return `${contentUri.rootUri}::${root}${newDocId}${query}`;
10389
}
90+
91+
// if pathname is undefined, meaning a docId/volume (e.g :primary:)
92+
// has not been detected, so no newDocId's ":" will be added.
93+
if (!pathname) {
94+
// Ensure proper path separator between root and newDocId
95+
let separator = "";
96+
if (root.endsWith("/") && newDocId.startsWith("/")) {
97+
// Both have separator, strip one from newDocId
98+
newDocId = newDocId.slice(1);
99+
} else if (!root.endsWith("/") && !newDocId.startsWith("/")) {
100+
// Neither has separator, add one
101+
separator = "/";
102+
}
103+
return `${contentUri.rootUri}::${root}${separator}${newDocId}${query}`;
104+
}
104105
return `${contentUri.rootUri}::${root}:${newDocId}${query}`;
105106
} catch (error) {
106107
return null;

0 commit comments

Comments
 (0)