11const path = require ( 'path' )
22const { getPathWithoutLanguage } = require ( '../lib/path-utils' )
3+ const nonEnterpriseDefaultVersion = require ( '../lib/non-enterprise-default-version' )
4+ const removeFPTFromPath = require ( '../lib/remove-fpt-from-path' )
35
46// Early Access content doesn't conform to the same structure as other products, so we
57// can't derive breadcrumbs from the siteTree in the same way. Hence, this separate middleware.
@@ -22,8 +24,13 @@ module.exports = async (req, res, next) => {
2224 // drop first '/'
2325 pathParts . shift ( )
2426
25- // drop the version and early-accesss segments so pathParts now starts with /product
26- pathParts . shift ( )
27+ // if this is not FPT, drop the version segment
28+ // if this is FPT, there is no version segment
29+ if ( req . context . currentVersion !== nonEnterpriseDefaultVersion ) {
30+ pathParts . shift ( )
31+ }
32+
33+ // drop the early-accesss segments so pathParts now starts with /product
2734 pathParts . shift ( )
2835
2936 // Early Access products do not require an index.md, so look for a matching public product
@@ -40,7 +47,7 @@ module.exports = async (req, res, next) => {
4047
4148 // get Early Access category path
4249 // e.g., `enforcing-best-practices-with-github-policies` in /free-pro-team@latest/early-access/github/enforcing-best-practices-with-github-policies
43- const categoryPath = path . posix . join ( '/' , 'en' , req . context . currentVersion , 'early-access' , pathParts [ 0 ] , pathParts [ 1 ] )
50+ const categoryPath = removeFPTFromPath ( path . posix . join ( '/' , 'en' , req . context . currentVersion , 'early-access' , pathParts [ 0 ] , pathParts [ 1 ] ) )
4451 const category = req . context . pages [ categoryPath ]
4552
4653 if ( ! category ) return next ( )
0 commit comments