Skip to content

Commit d94cc60

Browse files
committed
Fix deploy logic for custom domains
1 parent 076e7a1 commit d94cc60

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/deploy/plugin.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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(/\/?ADDON_DOCS_ROOT_URL\/?/g, `/${rootURL}/`)
158+
let updated = contents.replace(/\/?ADDON_DOCS_ROOT_URL\/?/g, addonDocsRootURL)
157159
.replace(/%22ADDON_DOCS_DEPLOY_VERSION%22/g, encodedVersion);
158160

159161
fs.writeFileSync(indexPath, updated);

0 commit comments

Comments
 (0)