Skip to content

Commit 5b75825

Browse files
authored
Fix product string bug (take 2) (#56330)
1 parent 784b71a commit 5b75825

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/frame/lib/path-utils.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export function getVersionObjectFromPath(href) {
9696
return allVersions[versionFromPath]
9797
}
9898

99+
// TODO needs refactoring + tests
99100
// Return the product segment from the path
100101
export function getProductStringFromPath(href) {
101102
href = getPathWithoutLanguage(href)
@@ -110,10 +111,15 @@ export function getProductStringFromPath(href) {
110111
// For rest pages the currentProduct should be rest
111112
// We use this to show SidebarRest, which is a different sidebar than the rest of the site
112113
if (pathParts[1] === 'rest') return 'rest'
113-
if (pathParts[1] === 'copilot') return 'copilot'
114-
if (pathParts[1] === 'get-started') return 'get-started'
115114

116-
return productIds.includes(pathParts[2]) ? pathParts[2] : pathParts[1]
115+
// Possible scenarios for href (assume part[0] is an empty string):
116+
//
117+
// * part[1] is a version and part[2] is undefined, so return part[1] as an enterprise landing page
118+
// * part[1] is a version and part[2] is defined, so return part[2] as the product
119+
// * part[1] is NOT a version, so return part[1] as the product
120+
const isEnterprise = supportedVersions.has(pathParts[1])
121+
const productString = isEnterprise && pathParts[2] ? pathParts[2] : pathParts[1]
122+
return productString
117123
}
118124

119125
export function getCategoryStringFromPath(href) {

0 commit comments

Comments
 (0)