Skip to content

Commit

Permalink
fix(dev-env): do not slugify domain if it matches the primary domain
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Dec 9, 2024
1 parent 4d802f9 commit d847c80
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/commands/dev-env-sync-sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ export class DevEnvSyncSQLCommand {
const networkSites = this.env.wpSitesSDS?.nodes;
if ( ! networkSites ) return;

const primaryUrl = networkSites.find( site => site?.blogId === 1 )?.homeUrl;
const primaryDomain = primaryUrl ? new URL( primaryUrl ).hostname : '';

for ( const site of networkSites ) {
if ( ! site?.blogId || site.blogId === 1 ) continue;

Expand All @@ -210,7 +213,10 @@ export class DevEnvSyncSQLCommand {
if ( ! this.searchReplaceMap[ strippedUrl ] ) continue;

const domain = new URL( url ).hostname;
const newDomain = `${ this.slugifyDomain( domain ) }.${ this.landoDomain }`;
const newDomain =
primaryDomain === domain
? this.landoDomain
: `${ this.slugifyDomain( domain ) }.${ this.landoDomain }`;

this.searchReplaceMap[ stripProtocol( url ) ] = stripProtocol(
replaceDomain( url, newDomain )
Expand Down

0 comments on commit d847c80

Please sign in to comment.