summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-01-06 14:25:42 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2011-01-06 14:25:42 -0500
commitef58d6735426a9ab3e6a7643c65926e362f7d157 (patch)
treefa620106b21cda5516c17d6ab697326b9066c5fd
parente2ce533559f5669a13d663c74d65610079162448 (diff)
Client-side redirects
-rw-r--r--lib/js/urweb.js4
-rw-r--r--src/jscomp.sml12
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index bba58453..3cb667d6 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -715,6 +715,10 @@ function unurlify(parse, s) {
return parse(s);
}
+function redirect(s) {
+ window.location = s;
+}
+
function rc(prefix, uri, parse, k, needsSig) {
uri = cat(prefix, uri);
uri = flattenLocal(uri);
diff --git a/src/jscomp.sml b/src/jscomp.sml
index 3b859814..dbbb83b2 100644
--- a/src/jscomp.sml
+++ b/src/jscomp.sml
@@ -875,7 +875,17 @@ fun process file =
| ENextval _ => unsupported "Nextval"
| ESetval _ => unsupported "Nextval"
| EReturnBlob _ => unsupported "EReturnBlob"
- | ERedirect _ => unsupported "ERedirect"
+
+ | ERedirect (e, _) =>
+ let
+ val (e, st) = jsE inner (e, st)
+ in
+ (strcat [str "{c:\"f\",f:\"redirect\",a:cons(",
+ e,
+ str ",null)}"],
+ st)
+ end
+
| EUnurlify (_, _, true) => unsupported "EUnurlify"
| EUnurlify (e, t, false) =>