From 3175ee735c4f753a8e1d70f5a9f47206f5a44a75 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Wed, 1 Jun 2011 07:23:27 -0400 Subject: Handle 'prefix' directives for HTTPS --- src/settings.sml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/settings.sml b/src/settings.sml index c60f5d60..69d67959 100644 --- a/src/settings.sml +++ b/src/settings.sml @@ -44,16 +44,21 @@ fun setUrlPrefix p = 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 -- cgit v1.2.3