comparison src/settings.sml @ 1470:5018878ca645

Handle 'prefix' directives for HTTPS
author Adam Chlipala <adam@chlipala.net>
date Wed, 01 Jun 2011 07:23:27 -0400
parents 2f5fd248588d
children a10d080123ec
comparison
equal deleted inserted replaced
1469:a354b306f948 1470:5018878ca645
42 else if String.sub (p, size p - 1) <> #"/" then 42 else if String.sub (p, size p - 1) <> #"/" then
43 p ^ "/" 43 p ^ "/"
44 else 44 else
45 p 45 p
46 46
47 fun findPrefix n =
48 let
49 val (befor, after) = Substring.splitl (fn ch => ch <> #"/") (Substring.extract (prefix, n, NONE))
50 in
51 if Substring.isEmpty after then
52 ("", prefix)
53 else
54 (String.substring (prefix, 0, n) ^ Substring.string befor, Substring.string after)
55 end
56
47 val (prepre, prefix) = 57 val (prepre, prefix) =
48 if String.isPrefix "http://" prefix then 58 if String.isPrefix "http://" prefix then
49 let 59 findPrefix 7
50 val (befor, after) = Substring.splitl (fn ch => ch <> #"/") (Substring.extract (prefix, 7, NONE)) 60 else if String.isPrefix "https://" prefix then
51 in 61 findPrefix 8
52 if Substring.isEmpty after then
53 ("", prefix)
54 else
55 ("http://" ^ Substring.string befor, Substring.string after)
56 end
57 else 62 else
58 ("", prefix) 63 ("", prefix)
59 in 64 in
60 urlPrePrefix := prepre; 65 urlPrePrefix := prepre;
61 urlPrefix := prefix 66 urlPrefix := prefix