MCPcopy
hub / github.com/github/docs / getProductStringFromPath

Function getProductStringFromPath

lib/path-utils.js:92–106  ·  view source on GitHub ↗
(href)

Source from the content-addressed store, hash-verified

90
91// Return the product segment from the path
92export function getProductStringFromPath(href) {
93 href = getPathWithoutLanguage(href)
94
95 if (href === '/') return 'homepage'
96
97 const pathParts = href.split('/')
98
99 if (pathParts.includes('early-access')) return 'early-access'
100
101 // For rest pages the currentProduct should be rest
102 // We use this to show SidebarRest, which is a different sidebar than the rest of the site
103 if (pathParts[1] === 'rest') return 'rest'
104
105 return productIds.includes(pathParts[2]) ? pathParts[2] : pathParts[1]
106}
107
108export function getCategoryStringFromPath(href) {
109 href = getPathWithoutLanguage(href)

Callers 2

contextualizeFunction · 0.85

Calls 1

getPathWithoutLanguageFunction · 0.85

Tested by

no test coverage detected