Skip to content

Commit

Permalink
Merge pull request #11823 from Automattic/add/error-message-for-no-do…
Browse files Browse the repository at this point in the history
…main

Domain only flow: redirect when starting the flow with a bad domain name
  • Loading branch information
Tug authored Mar 8, 2017
2 parents e35a5dc + 23ddb79 commit 8142264
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions client/signup/steps/site-or-domain/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import page from 'page';
import React, { Component } from 'react';

/**
Expand All @@ -15,14 +14,28 @@ import Card from 'components/card';
// TODO: `design-type-with-store`, `design-type`, and this component could be refactored to reduce redundancy
import DomainImage from 'signup/steps/design-type-with-store/domain-image';
import PageImage from 'signup/steps/design-type-with-store/page-image';
import { getStepUrl } from 'signup/utils';
import { externalRedirect } from 'lib/route/path';

export default class SiteOrDomain extends Component {
componentWillMount() {
const { queryObject } = this.props;
let isValidDomain = queryObject && queryObject.new;

if ( ! queryObject || ! queryObject.new ) {
page( getStepUrl( 'main' ) );
if ( isValidDomain ) {
const domainParts = queryObject.new.split( '.' );

if ( domainParts.length > 1 ) {
const tld = domainParts.slice( 1 ).join( '.' );
isValidDomain = !! tlds[ tld ];
} else {
isValidDomain = false;
}
}

if ( ! isValidDomain ) {
// /domains domain search is an external application to calypso,
// therefor a full redirect required:
externalRedirect( '/domains' );
}
}

Expand Down

0 comments on commit 8142264

Please sign in to comment.