Skip to content

Commit ca4ca63

Browse files
committed
Add comments
1 parent 71489fd commit ca4ca63

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/store.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,15 @@ export function processBaseUrls(
765765
function processCustomBaseUrls(config: SDKInitConfig): Dictionary<string> {
766766
const defaultBaseUrls: Dictionary<string> = Constants.DefaultBaseUrls;
767767
const CNAMEUrlPaths: Dictionary<string> = Constants.CNAMEUrlPaths;
768+
769+
// newBaseUrls are default if the customer is not using a CNAME
770+
// If a customer passes either config.domain or config.v3SecureServiceUrl,
771+
// config.identityUrl, etc, the customer is using a CNAME.
772+
// config.domain will take priority if a customer passes both.
768773
const newBaseUrls: Dictionary<string> = {};
769-
// If config.domain exists, the customer is using a CNAME, and we append the url paths to the domain
774+
// If config.domain exists, the customer is using a CNAME. We append the url paths to the provided domain.
775+
// This flag is set on the Rokt/MP snippet (starting at version 2.6), meaning config.domain will alwys be empty
776+
// if a customer is using a snippet prior to 2.6.
770777
if (!isEmpty(config.domain)) {
771778
for (let pathKey in CNAMEUrlPaths) {
772779
newBaseUrls[pathKey] = `${config.domain}${CNAMEUrlPaths[pathKey]}`;

test/src/tests-store.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,8 @@ describe('Store', () => {
15431543
});
15441544

15451545
it('should append url paths to domain when config.domain is set', () => {
1546+
// This example assumes only the domain is set, and not any of the
1547+
// configurable URLs
15461548
const config = {
15471549
domain: 'custom.domain.com'
15481550
};
@@ -1566,6 +1568,9 @@ describe('Store', () => {
15661568
});
15671569

15681570
it('should prioritize domain over custom baseUrls when both are set', () => {
1571+
// If both the domain and other configurable URLs are set, then
1572+
// we use the domain. A customer should not be passing in both, as
1573+
// that would be an implementation error.
15691574
const config = {
15701575
domain: 'custom.domain.com',
15711576
v1SecureServiceUrl: 'foo.customer.mp.com/v1/JS/',

0 commit comments

Comments
 (0)