Skip to content

Commit

Permalink
fix: netlify constants
Browse files Browse the repository at this point in the history
  • Loading branch information
milljoniaer committed Nov 28, 2023
1 parent c189f4b commit fe5d924
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gatsby/config-options/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const NETLIFY_DOMAIN_NAME = process.env.GATSBY_NETLIFY_DOMAIN_NAME || '';
export const BRANCH_PREVIEW_URL = buildNetlifyPreviewUrl({
domainName: NETLIFY_DOMAIN_NAME,
branch: process.env.BRANCH,
previewId: process.env.PREVIEW_ID,
reviewId: process.env.REVIEW_ID,
});

// either use a branch preview url if any
Expand Down
6 changes: 3 additions & 3 deletions gatsby/util/build-netlify-preview-url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('build-netlify-preview-url', () => {
const url = buildNetlifyPreviewUrl({
domainName: 'satellytes',
branch: 'feature-branch-1',
previewId: '123',
reviewId: '123',
});
expect(url).toBe('https://deploy-preview-123--satellytes.netlify.app/');
});
Expand All @@ -14,7 +14,7 @@ describe('build-netlify-preview-url', () => {
const url = buildNetlifyPreviewUrl({
domainName: 'satellytescommain',
branch: 'main',
previewId: '123',
reviewId: '123',
});
expect(url).toBe(null);
});
Expand All @@ -23,7 +23,7 @@ describe('build-netlify-preview-url', () => {
const url = buildNetlifyPreviewUrl({
domainName: null,
branch: 'something',
previewId: '123',
reviewId: '123',
});
expect(url).toBe(null);
});
Expand Down
6 changes: 3 additions & 3 deletions gatsby/util/build-netlify-preview-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
*/

const PRODUCTION_BRANCH = 'main';
export const buildNetlifyPreviewUrl = ({ domainName, previewId, branch }) => {
if (!domainName || !previewId || branch === PRODUCTION_BRANCH) {
export const buildNetlifyPreviewUrl = ({ domainName, reviewId, branch }) => {
if (!domainName || !reviewId || branch === PRODUCTION_BRANCH) {
return null;
}

return `https://deploy-preview-${previewId}--${domainName}.netlify.app/`;
return `https://deploy-preview-${reviewId}--${domainName}.netlify.app/`;
};

0 comments on commit fe5d924

Please sign in to comment.