]> gitweb.factorcode.org Git - factor.git/commitdiff
urls.encoding: more cleanup.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 1 Dec 2014 05:33:48 +0000 (21:33 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 1 Dec 2014 05:33:48 +0000 (21:33 -0800)
basis/urls/encoding/encoding.factor

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