webapps.wee-url: random-url can use random-string

char-rename
Björn Lindqvist 2016-10-26 09:06:19 +02:00
parent 417e296d46
commit 4dbc377383
1 changed files with 5 additions and 12 deletions

View 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