@@ -56,7 +56,7 @@ module.exports = function getOldPathsFromPath (currentPath, languageCode, curren
5656
5757 // ------ BEGIN MODERN VERSION FORMAT REPLACEMENTS ------//
5858 if ( currentlySupportedVersions . includes ( currentVersion ) || versionSatisfiesRange ( currentVersion , `>${ lastReleaseWithLegacyFormat } ` ) ) {
59- oldPaths . forEach ( oldPath => {
59+ ( new Set ( oldPaths ) ) . forEach ( oldPath => {
6060 // create old path /github from new path /free-pro-team@latest/github
6161 oldPaths . add ( oldPath
6262 . replace ( `/${ nonEnterpriseDefaultVersion } ` , '' ) )
@@ -107,19 +107,22 @@ module.exports = function getOldPathsFromPath (currentPath, languageCode, curren
107107 // ------ END MODERN VERSION FORMAT REPLACEMENTS ------//
108108
109109 // For each old path added to the set above, do the following...
110+ ( new Set ( oldPaths ) ) . forEach ( oldPath => {
111+ // for English only, remove language code
112+ if ( languageCode === 'en' ) {
113+ oldPaths . add ( getPathWithoutLanguage ( oldPath ) )
114+ }
110115
111- // add language code
112- oldPaths . forEach ( oldPath => oldPaths . add ( getPathWithLanguage ( oldPath , languageCode ) ) )
116+ // add language code
117+ oldPaths . add ( getPathWithLanguage ( oldPath , languageCode ) )
113118
114- // for English only, remove language code
115- if ( languageCode === 'en' ) {
116- oldPaths . forEach ( oldPath => oldPaths . add ( getPathWithoutLanguage ( oldPath ) ) )
117- }
119+ // create /enterprise from /enterprise/latest
120+ oldPaths . add ( oldPath . replace ( `/enterprise/${ latest } ` , '/enterprise' ) )
121+ } )
118122
119- // create /enterprise from /enterprise/latest
120- oldPaths . forEach ( oldPath => oldPaths . add ( oldPath . replace ( `/enterprise/${ latest } ` , '/enterprise' ) ) )
123+ // exclude any empty old paths that may have been derived
124+ oldPaths . delete ( '' )
125+ oldPaths . delete ( '/' )
121126
122- return Array . from ( oldPaths )
123- // exclude any empty old paths that may have been derived
124- . filter ( oldPath => oldPath !== '' && oldPath !== '/' )
127+ return oldPaths
125128}
0 commit comments