File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff 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
100101export 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
119125export function getCategoryStringFromPath ( href ) {
You can’t perform that action at this time.
0 commit comments