@jaypie/constructs 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -394,10 +394,17 @@ function envHostname({ component, domain, env, subdomain, } = {}) {
394
394
  const resolvedSubdomain = providedSubdomain || process.env.CDK_ENV_SUBDOMAIN;
395
395
  const resolvedEnv = env || process.env.PROJECT_ENV;
396
396
  const filteredEnv = resolvedEnv === CDK$2.ENV.PRODUCTION ? undefined : resolvedEnv;
397
+ // Check if parts are already contained in the domain to avoid duplication
398
+ const domainParts = resolvedDomain.split(".");
399
+ const isPartInDomain = (part) => {
400
+ if (!part)
401
+ return false;
402
+ return domainParts.includes(part);
403
+ };
397
404
  const parts = [
398
- resolvedComponent,
399
- resolvedSubdomain,
400
- filteredEnv,
405
+ isPartInDomain(resolvedComponent) ? undefined : resolvedComponent,
406
+ isPartInDomain(resolvedSubdomain) ? undefined : resolvedSubdomain,
407
+ isPartInDomain(filteredEnv) ? undefined : filteredEnv,
401
408
  resolvedDomain,
402
409
  ].filter((part) => part);
403
410
  return parts.join(".");