@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.
package/dist/esm/index.js CHANGED
@@ -363,10 +363,17 @@ function envHostname({ component, domain, env, subdomain, } = {}) {
363
363
  const resolvedSubdomain = providedSubdomain || process.env.CDK_ENV_SUBDOMAIN;
364
364
  const resolvedEnv = env || process.env.PROJECT_ENV;
365
365
  const filteredEnv = resolvedEnv === CDK$2.ENV.PRODUCTION ? undefined : resolvedEnv;
366
+ // Check if parts are already contained in the domain to avoid duplication
367
+ const domainParts = resolvedDomain.split(".");
368
+ const isPartInDomain = (part) => {
369
+ if (!part)
370
+ return false;
371
+ return domainParts.includes(part);
372
+ };
366
373
  const parts = [
367
- resolvedComponent,
368
- resolvedSubdomain,
369
- filteredEnv,
374
+ isPartInDomain(resolvedComponent) ? undefined : resolvedComponent,
375
+ isPartInDomain(resolvedSubdomain) ? undefined : resolvedSubdomain,
376
+ isPartInDomain(filteredEnv) ? undefined : filteredEnv,
370
377
  resolvedDomain,
371
378
  ].filter((part) => part);
372
379
  return parts.join(".");