From 2d42674e1ae13db816ad6c7842a73c71cba33929 Mon Sep 17 00:00:00 2001 From: "R. Miles McCain" Date: Tue, 11 Aug 2020 21:39:08 +0000 Subject: [PATCH] Add warning when hostname starts with http (fixes #68) --- shynet/core/management/commands/hostname.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shynet/core/management/commands/hostname.py b/shynet/core/management/commands/hostname.py index 7174a41..dcb7059 100644 --- a/shynet/core/management/commands/hostname.py +++ b/shynet/core/management/commands/hostname.py @@ -20,6 +20,12 @@ class Command(BaseCommand): def handle(self, *args, **options): site = Site.objects.get(pk=settings.SITE_ID) site.domain = options.get("hostname") + if options.get("hostname").lower().startswith("http"): + self.stdout.write( + self.style.WARNING( + f"Warning: the hostname '{options.get('hostname')}' starts with `http`. You almost certainly don't want this. The hostname is supposed to be the raw domain name of your Shynet instance, without `http://` or `https://`. For example, if your Shynet instance will eventually be hosted at `https://analytics.example.com`, the hostname should be `analytics.example.com`." + ) + ) site.save() self.stdout.write( self.style.SUCCESS(