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) {
96
96
return allVersions [ versionFromPath ]
97
97
}
98
98
99
+ // TODO needs refactoring + tests
99
100
// Return the product segment from the path
100
101
export function getProductStringFromPath ( href ) {
101
102
href = getPathWithoutLanguage ( href )
@@ -110,10 +111,15 @@ export function getProductStringFromPath(href) {
110
111
// For rest pages the currentProduct should be rest
111
112
// We use this to show SidebarRest, which is a different sidebar than the rest of the site
112
113
if ( pathParts [ 1 ] === 'rest' ) return 'rest'
113
- if ( pathParts [ 1 ] === 'copilot' ) return 'copilot'
114
- if ( pathParts [ 1 ] === 'get-started' ) return 'get-started'
115
114
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
117
123
}
118
124
119
125
export function getCategoryStringFromPath ( href ) {
You can’t perform that action at this time.
0 commit comments