]> gitweb.factorcode.org Git - factor.git/commitdiff
webapps.wee-url: random-url can use random-string
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 26 Oct 2016 07:06:19 +0000 (09:06 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Wed, 26 Oct 2016 07:06:19 +0000 (09:06 +0200)
extra/webapps/wee-url/wee-url.factor

index 1d9b5e211b023481f89455cfd9eca3cc2ef46422..ee3cd252bc152d9a9bee93eebc91be66b7078512 100644 (file)
@@ -1,11 +1,10 @@
 ! Copyright (C) 2007 Doug Coleman.
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: math.ranges sequences random accessors
-kernel namespaces fry db.types db.tuples urls validators
-html.components html.forms http http.server.dispatchers furnace
-furnace.actions furnace.boilerplate furnace.redirection
-furnace.utilities continuations ;
+USING: accessors continuations db.tuples db.types fry furnace.actions
+furnace.boilerplate furnace.redirection furnace.utilities html.forms
+http.server.dispatchers kernel math math.ranges random random.data
+sequences urls validators ;
 IN: webapps.wee-url
 
 TUPLE: wee-url < dispatcher ;
@@ -17,14 +16,8 @@ short-url "SHORT_URLS" {
     { "url" "URL" TEXT +not-null+ }
 } define-persistent
 
-: letter-bank ( -- seq )
-    CHAR: a CHAR: z [a,b]
-    CHAR: A CHAR: Z [a,b]
-    CHAR: 1 CHAR: 0 [a,b]
-    3append ; foldable
-
 : random-url ( -- string )
-    1 6 [a,b] random [ letter-bank random ] "" replicate-as ;
+    6 random 1 + random-string ;
 
 : retry ( quot: ( -- ? )  n -- )
     swap [ drop ] prepose attempt-all ; inline