Skip to content

Commit

Permalink
fix(amplify-console-hosting): added a null check for prefix on domain (
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanndorin authored and sebastiancrossa committed Aug 24, 2020
1 parent 121f1b5 commit 5fc674d
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions packages/amplify-console-hosting/utils/table-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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]]);
}
Expand All @@ -70,7 +81,6 @@ async function generateTableContentForApp(context, appId) {
}
}


module.exports = {
generateTableContentForApp,
};

0 comments on commit 5fc674d

Please sign in to comment.