Skip to content

Commit 8744cf6

Browse files
committed
@W-22283814: Fix prettier formatting and default preserveUserAgent to true
1 parent b32e374 commit 8744cf6

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

packages/mrt-utilities/src/utils/ssr-proxying.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -770,14 +770,9 @@ export const X_HEADERS_TO_REMOVE_PROXY: string[] = ['x-mobify-access-key'];
770770

771771
const X_SFDC_ACCESS_CONTROL = 'x-sfdc-access-control';
772772

773-
export const DEFAULT_ACCESS_CONTROL_FORWARDING_HOSTNAMES: string[] = [
774-
'.commercecloud.salesforce.com',
775-
];
773+
export const DEFAULT_ACCESS_CONTROL_FORWARDING_HOSTNAMES: string[] = ['.commercecloud.salesforce.com'];
776774

777-
export const hostnameMatchesTransformationList = (
778-
hostname: string,
779-
hostnameSuffixes?: string[] | null,
780-
): boolean => {
775+
export const hostnameMatchesTransformationList = (hostname: string, hostnameSuffixes?: string[] | null): boolean => {
781776
if (!hostnameSuffixes || hostnameSuffixes.length === 0) {
782777
return false;
783778
}
@@ -891,7 +886,7 @@ export const rewriteProxyRequestHeaders = ({
891886
targetHost,
892887
logging = false,
893888
accessControlHeaderForwardingHostnames,
894-
preserveUserAgent = false,
889+
preserveUserAgent = true,
895890
}: RewriteProxyRequestHeadersParams): AWSHeaders | HTTPHeaders | IncomingHttpHeaders => {
896891
if (!headers) {
897892
return {};

packages/mrt-utilities/test/utils/ssr-proxying.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,13 +805,13 @@ describe('rewriteProxyRequestHeaders tests', () => {
805805
},
806806
},
807807
{
808-
name: 'overwrites User-Agent when preserveUserAgent is undefined (default)',
808+
name: 'preserves User-Agent when preserveUserAgent is undefined (default is true)',
809809
targetHost: 'www.customer.com',
810810
input: {
811811
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X)',
812812
},
813813
expected: {
814-
'user-agent': 'Amazon CloudFront',
814+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X)',
815815
},
816816
},
817817
{
@@ -901,8 +901,8 @@ describe('hostnameMatchesTransformationList', () => {
901901
});
902902

903903
it('returns true when hostname ends with a suffix', () => {
904-
expect(hostnameMatchesTransformationList('api.commercecloud.salesforce.com', ['.commercecloud.salesforce.com']))
905-
.to.be.true;
904+
expect(hostnameMatchesTransformationList('api.commercecloud.salesforce.com', ['.commercecloud.salesforce.com'])).to
905+
.be.true;
906906
});
907907

908908
it('returns true with multiple suffixes', () => {

0 commit comments

Comments
 (0)