From 81bd2eb175824fba470ea11a235b8173080db48e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 29 Sep 2008 22:54:10 -0500 Subject: [PATCH] Remove raw-query stuff, its a pain --- basis/urls/urls-tests.factor | 5 ----- basis/urls/urls.factor | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/basis/urls/urls-tests.factor b/basis/urls/urls-tests.factor index c98802657b..cac206bf3c 100644 --- a/basis/urls/urls-tests.factor +++ b/basis/urls/urls-tests.factor @@ -10,7 +10,6 @@ arrays kernel assocs present accessors ; { host "www.apple.com" } { port 1234 } { path "/a/path" } - { raw-query "a=b" } { query H{ { "a" "b" } } } { anchor "foo" } } @@ -21,7 +20,6 @@ arrays kernel assocs present accessors ; { protocol "http" } { host "www.apple.com" } { path "/a/path" } - { raw-query "a=b" } { query H{ { "a" "b" } } } { anchor "foo" } } @@ -59,7 +57,6 @@ arrays kernel assocs present accessors ; { T{ url { path "bar" } - { raw-query "a=b" } { query H{ { "a" "b" } } } } "bar?a=b" @@ -213,7 +210,6 @@ urls [ T{ url { protocol "http" } { host "localhost" } - { raw-query "foo=bar" } { query H{ { "foo" "bar" } } } { path "/" } } @@ -224,7 +220,6 @@ urls [ T{ url { protocol "http" } { host "localhost" } - { raw-query "foo=bar" } { query H{ { "foo" "bar" } } } { path "/" } } diff --git a/basis/urls/urls.factor b/basis/urls/urls.factor index fb56e274da..5cc8c9693b 100644 --- a/basis/urls/urls.factor +++ b/basis/urls/urls.factor @@ -8,7 +8,7 @@ strings.parser lexer prettyprint.backend hashtables present peg.ebnf urls.encoding ; IN: urls -TUPLE: url protocol username password host port path raw-query query anchor ; +TUPLE: url protocol username password host port path query anchor ; : ( -- url ) url new ; @@ -47,7 +47,7 @@ protocol = [a-z]+ => [[ url-decode ]] username = [^/:@#?]+ => [[ url-decode ]] password = [^/:@#?]+ => [[ url-decode ]] pathname = [^#?]+ => [[ url-decode ]] -query = [^#]+ => [[ >string ]] +query = [^#]+ => [[ query>assoc ]] anchor = .+ => [[ url-decode ]] hostname = [^/#?]+ => [[ url-decode ]] @@ -80,7 +80,7 @@ M: string >url ] [ f f f f f ] if* ] [ second ] ! pathname - [ third dup query>assoc ] ! query + [ third ] ! query [ fourth ] ! anchor } cleave url boa dup host>> [ [ "/" or ] change-path ] when ; @@ -139,14 +139,14 @@ PRIVATE> : derive-url ( base url -- url' ) [ clone ] dip over { - [ [ protocol>> ] either? >>protocol ] - [ [ username>> ] either? >>username ] - [ [ password>> ] either? >>password ] - [ [ host>> ] either? >>host ] - [ [ port>> ] either? >>port ] - [ [ path>> ] bi@ swap url-append-path >>path ] - [ [ query>> ] either? >>query ] - [ [ anchor>> ] either? >>anchor ] + [ [ protocol>> ] either? >>protocol ] + [ [ username>> ] either? >>username ] + [ [ password>> ] either? >>password ] + [ [ host>> ] either? >>host ] + [ [ port>> ] either? >>port ] + [ [ path>> ] bi@ swap url-append-path >>path ] + [ [ query>> ] either? >>query ] + [ [ anchor>> ] either? >>anchor ] } 2cleave ; : relative-url ( url -- url' )