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