changeset 1470:5018878ca645

Handle 'prefix' directives for HTTPS
author Adam Chlipala <adam@chlipala.net>
date Wed, 01 Jun 2011 07:23:27 -0400 (2011-06-01)
parents a354b306f948
children 67ebd30a2283
files src/settings.sml
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/settings.sml	Tue May 31 09:14:03 2011 -0400
+++ b/src/settings.sml	Wed Jun 01 07:23:27 2011 -0400
@@ -44,16 +44,21 @@
                      else
                          p
 
+        fun findPrefix n =
+            let
+                val (befor, after) = Substring.splitl (fn ch => ch <> #"/") (Substring.extract (prefix, n, NONE))
+            in
+                if Substring.isEmpty after then
+                    ("", prefix)
+                else
+                    (String.substring (prefix, 0, n) ^ Substring.string befor, Substring.string after)
+            end            
+
         val (prepre, prefix) =
             if String.isPrefix "http://" prefix then
-                let
-                    val (befor, after) = Substring.splitl (fn ch => ch <> #"/") (Substring.extract (prefix, 7, NONE))
-                in
-                    if Substring.isEmpty after then
-                        ("", prefix)
-                    else
-                        ("http://" ^ Substring.string befor, Substring.string after)
-                end
+                findPrefix 7
+            else if String.isPrefix "https://" prefix then
+                findPrefix 8
             else
                 ("", prefix)
     in