From c715edf57a6b76c127939e4fc2759cf1ab045cd3 Mon Sep 17 00:00:00 2001
From: cahrens <christina@edx.org>
Date: Thu, 6 Jun 2013 10:55:41 -0400
Subject: [PATCH] Strip off https://

---
 cms/djangoapps/contentstore/tests/test_utils.py | 18 ++++++++++++++++++
 cms/djangoapps/contentstore/utils.py            |  7 +++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/cms/djangoapps/contentstore/tests/test_utils.py b/cms/djangoapps/contentstore/tests/test_utils.py
index 0c33c2d..fec82db 100644
--- a/cms/djangoapps/contentstore/tests/test_utils.py
+++ b/cms/djangoapps/contentstore/tests/test_utils.py
@@ -24,6 +24,24 @@ class LMSLinksTestCase(TestCase):
         with mock.patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': False}):
             self.assertEquals(self.get_about_page_link(), "//localhost:8000/courses/mitX/101/test/about")
 
+    @override_settings(MKTG_URLS={'ROOT': 'http://www.dummy'})
+    def about_page_marketing_site_remove_http_test(self):
+        """ Get URL for about page, marketing root present, remove http://. """
+        with mock.patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': True}):
+            self.assertEquals(self.get_about_page_link(), "//www.dummy/courses/mitX/101/test/about")
+
+    @override_settings(MKTG_URLS={'ROOT': 'https://www.dummy'})
+    def about_page_marketing_site_remove_https_test(self):
+        """ Get URL for about page, marketing root present, remove https://. """
+        with mock.patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': True}):
+            self.assertEquals(self.get_about_page_link(), "//www.dummy/courses/mitX/101/test/about")
+
+    @override_settings(MKTG_URLS={'ROOT': 'www.dummyhttps://x'})
+    def about_page_marketing_site_https__edge_test(self):
+        """ Get URL for about page, only remove https:// at the beginning of the string. """
+        with mock.patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': True}):
+            self.assertEquals(self.get_about_page_link(), "//www.dummyhttps://x/courses/mitX/101/test/about")
+
     @override_settings(MKTG_URLS={})
     def about_page_marketing_urls_not_set_test(self):
         """ Error case. ENABLE_MKTG_SITE is True, but there is either no MKTG_URLS, or no MKTG_URLS Root property. """
diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py
index 83c413a..e9b6233 100644
--- a/cms/djangoapps/contentstore/utils.py
+++ b/cms/djangoapps/contentstore/utils.py
@@ -5,6 +5,7 @@ from xmodule.modulestore.exceptions import ItemNotFoundError
 from django.core.urlresolvers import reverse
 import copy
 import logging
+import re
 
 log = logging.getLogger(__name__)
 
@@ -120,9 +121,11 @@ def get_lms_link_for_about_page(location):
                 log.exception('There is no ROOT defined in MKTG_URLS')
                 about_base = None
             else:
-                # Root will be "www.edx.org". The complete URL will still not be exactly correct,
-                # but redirects exist from www.edx.org to get to the drupal course about page URL.
+                # Root will be "https://www.edx.org". The complete URL will still not be exactly correct,
+                # but redirects exist from www.edx.org to get to the Drupal course about page URL.
                 about_base = marketing_urls.get('ROOT')
+                # Strip off https:// (or http://) to be consistent with the formatting of LMS_BASE.
+                about_base = re.sub(r"^https?://", "", about_base)
     elif settings.LMS_BASE is not None:
         about_base = settings.LMS_BASE
     else:
--
libgit2 0.26.0