@@ -64,7 +64,8 @@ module.exports = class AddonDocsDeployPlugin {
6464
6565 _verifyRedirectFile ( stagingDirectory ) {
6666 let vendorDir = `${ __dirname } /../../vendor/ember-cli-addon-docs` ;
67- let segmentCount = this . _getRootURL ( ) . split ( '/' ) . length ;
67+ let rootURL = this . _getRootURL ( ) ;
68+ let segmentCount = rootURL === '' ? 0 : rootURL . split ( '/' ) . length ;
6869 let redirectContents = fs . readFileSync ( `${ vendorDir } /404.html` , 'utf-8' ) ;
6970 let redirects = this . _discoverOldPaths ( stagingDirectory ) ;
7071
@@ -151,9 +152,10 @@ module.exports = class AddonDocsDeployPlugin {
151152 _updateIndexContents ( context , stagingDirectory , appRoot , deployVersion ) {
152153 let indexPath = `${ stagingDirectory } /${ appRoot } /index.html` ;
153154 let rootURL = [ this . _getRootURL ( ) , appRoot ] . filter ( Boolean ) . join ( '/' ) ;
155+ let addonDocsRootURL = rootURL === '' ? '/' : `/${ rootURL } /` ;
154156 let contents = fs . readFileSync ( indexPath , 'utf-8' ) ;
155157 let encodedVersion = encodeURIComponent ( JSON . stringify ( deployVersion ) ) ;
156- let updated = contents . replace ( / \/ ? A D D O N _ D O C S _ R O O T _ U R L \/ ? / g, `/ ${ rootURL } /` )
158+ let updated = contents . replace ( / \/ ? A D D O N _ D O C S _ R O O T _ U R L \/ ? / g, addonDocsRootURL )
157159 . replace ( / % 2 2 A D D O N _ D O C S _ D E P L O Y _ V E R S I O N % 2 2 / g, encodedVersion ) ;
158160
159161 fs . writeFileSync ( indexPath , updated ) ;
0 commit comments