urls.encoding: more cleanup.

db4
John Benediktsson 2014-11-30 21:33:48 -08:00
parent b00e5a855b
commit 6f1e819e04
1 changed files with 9 additions and 18 deletions

View File

@ -81,23 +81,12 @@ PRIVATE>
: add-query-param ( value key assoc -- ) : add-query-param ( value key assoc -- )
[ [
at [
{ {
{ [ dup string? ] [ swap 2array ] } { [ dup string? ] [ swap 2array ] }
{ [ dup array? ] [ swap suffix ] } { [ dup array? ] [ swap suffix ] }
{ [ dup not ] [ drop ] } { [ dup not ] [ drop ] }
} cond } cond
] when* ] change-at ;
] 2keep set-at ;
: assoc-strings ( assoc -- assoc' )
[
{
{ [ dup not ] [ ] }
{ [ dup array? ] [ [ present ] map ] }
[ present 1array ]
} cond
] assoc-map ;
PRIVATE> PRIVATE>
@ -113,8 +102,10 @@ PRIVATE>
: assoc>query ( assoc -- str ) : assoc>query ( assoc -- str )
[ [
assoc-strings [ [
[ url-encode-full ] dip [ url-encode-full ] dip [
[ [ url-encode-full "=" glue , ] with each ] [ , ] if* dup array? [ 1array ] unless
[ present url-encode-full "=" glue , ] with each
] [ , ] if*
] assoc-each ] assoc-each
] { } make "&" join ; ] { } make "&" join ;