Browse Source

domain validate code

bugfixes
harshadyeola 10 years ago
parent
commit
f038463b28
  1. 4
      ee/cli/plugins/site.py
  2. 20
      ee/core/domainvalidate.py

4
ee/cli/plugins/site.py

@ -1,6 +1,7 @@
"""EasyEngine site controller.""" """EasyEngine site controller."""
from cement.core.controller import CementBaseController, expose from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook from cement.core import handler, hook
from ee.core.domainvalidate import validate_domain
import sys import sys
@ -107,6 +108,9 @@ class EESiteCreateController(CementBaseController):
# TODO Default action for ee site command # TODO Default action for ee site command
# data = dict(foo='EESiteCreateController.default().') # data = dict(foo='EESiteCreateController.default().')
# self.app.render((data), 'default.mustache') # self.app.render((data), 'default.mustache')
# Check domain name validation
ee_domain_name = validate_domain(self.app.pargs.site_name)
if (self.app.pargs.html and not (self.app.pargs.php or if (self.app.pargs.html and not (self.app.pargs.php or
self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc
or self.app.pargs.wpfc or self.app.pargs.wpsc or or self.app.pargs.wpfc or self.app.pargs.wpsc or

20
ee/core/domainvalidate.py

@ -0,0 +1,20 @@
from urllib.parse import urlparse
def validate_domain(url):
# Check if http:// or https:// present remove it if present
domain_name = url.split('/')
if 'http:' in domain_name or 'https:' in domain_name:
domain_name = domain_name[2]
else:
domain_name = domain_name[0]
www_domain_name = domain_name.split('.')
final_domain = ''
if www_domain_name[0] == 'www':
final_domain = '.'.join(www_domain_name[1:])
return final_domain
else:
final_domain = domain_name
return final_domain
Loading…
Cancel
Save