summaryrefslogtreecommitdiff
path: root/src/settings.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2010-12-26 17:29:03 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2010-12-26 17:29:03 -0500
commitad00c1edb8f819c4489dbf1e2106108f92e7bf98 (patch)
tree897f72fa64ec732b9a26c428c5ddeb9a0d7f6cf6 /src/settings.sml
parentbfbe3b9c6870d6a501816c080b52d9e0c922db6c (diff)
queryString and effectfulUrl
Diffstat (limited to 'src/settings.sml')
-rw-r--r--src/settings.sml32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/settings.sml b/src/settings.sml
index 5b4bbe2c..29bbb1d8 100644
--- a/src/settings.sml
+++ b/src/settings.sml
@@ -28,18 +28,38 @@
structure Settings :> SETTINGS = struct
val urlPrefix = ref "/"
+val urlPrePrefix = ref ""
val timeout = ref 0
val headers = ref ([] : string list)
val scripts = ref ([] : string list)
fun getUrlPrefix () = !urlPrefix
+fun getUrlPrePrefix () = !urlPrePrefix
fun setUrlPrefix p =
- urlPrefix := (if p = "" then
- "/"
- else if String.sub (p, size p - 1) <> #"/" then
- p ^ "/"
- else
- p)
+ let
+ val prefix = if p = "" then
+ "/"
+ else if String.sub (p, size p - 1) <> #"/" then
+ p ^ "/"
+ else
+ p
+
+ 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
+ else
+ ("", prefix)
+ in
+ urlPrePrefix := prepre;
+ urlPrefix := prefix
+ end
fun getTimeout () = !timeout
fun setTimeout n = timeout := n