From 5fc674d27c5602f333ac6284f20af2f75bfb034f Mon Sep 17 00:00:00 2001 From: Max Scholz Date: Wed, 15 Jul 2020 03:12:42 +0200 Subject: [PATCH] fix(amplify-console-hosting): added a null check for prefix on domain (#4809) --- .../utils/table-utils.js | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/amplify-console-hosting/utils/table-utils.js b/packages/amplify-console-hosting/utils/table-utils.js index 0a6daabfa15..5a7076a9a69 100644 --- a/packages/amplify-console-hosting/utils/table-utils.js +++ b/packages/amplify-console-hosting/utils/table-utils.js @@ -11,10 +11,12 @@ async function generateTableContentForApp(context, appId) { let nextToken = null; try { do { - const { branches } = await amplifyClient.listBranches({ - appId, - nextToken, - }).promise(); + const { branches } = await amplifyClient + .listBranches({ + appId, + nextToken, + }) + .promise(); for (const branch of branches) { const { branchName } = branch; @@ -25,10 +27,12 @@ async function generateTableContentForApp(context, appId) { nextToken = null; do { - const { domainAssociations } = await amplifyClient.listDomainAssociations({ - appId, - nextToken, - }).promise(); + const { domainAssociations } = await amplifyClient + .listDomainAssociations({ + appId, + nextToken, + }) + .promise(); for (const domainAssociation of domainAssociations) { const { domainName, subDomains } = domainAssociation; @@ -37,7 +41,11 @@ async function generateTableContentForApp(context, appId) { if (!domainMap[branchName]) { domainMap[branchName] = []; } - domainMap[branchName].push(`https://${prefix}.${domainName}`); + if (prefix === null || prefix === undefined) { + domainMap[branchName].push(`https://${domainName}`); + } else { + domainMap[branchName].push(`https://${prefix}.${domainName}`); + } } } } while (nextToken != null); @@ -54,10 +62,13 @@ async function generateTableContentForApp(context, appId) { for (const [branchName, domains] of Object.entries(domainMap)) { for (let index = 0; index < domains.length; index++) { if (index === 0) { - table.push([{ - rowSpan: domains.length, - content: branchName, - }, domains[index]]); + table.push([ + { + rowSpan: domains.length, + content: branchName, + }, + domains[index], + ]); } else { table.push([domains[index]]); } @@ -70,7 +81,6 @@ async function generateTableContentForApp(context, appId) { } } - module.exports = { generateTableContentForApp, };