Added machine-parsable links database, per-page links and page source.
[cocanwiki.git] / scripts / lib / wikilib.ml
index 0ba0425..7916201 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: wikilib.ml,v 1.1 2004/10/21 11:42:05 rich Exp $
+ * $Id: wikilib.ml,v 1.2 2004/10/24 17:32:55 rich Exp $
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -55,6 +55,9 @@ let generate_url_of_title (dbh : Dbi.connection) hostid title =
   (* URL cannot begin with '_'. *)
   else if url.[0] = '_' then
     GenURL_BadURL
+  (* Titles which begin or end with spaces are probably mistakes. *)
+  else if isspace title.[0] || isspace title.[String.length title - 1] then
+    GenURL_BadURL
   else (
     (* Check that the URL doesn't already exist in the database.  If it does
      * then it probably means that another page exists with similar enough