swap [ 1array ] [ [ present ] curry ] bi* unit-test
] assoc-each
+{ T{ url
+ { protocol "http" }
+ { username "ш" }
+ { password "ш" }
+ { host "ш.com" }
+ { port 1234 }
+ { path "/ш" }
+ { query LH{ { "ш" "ш" } } }
+ { anchor "ш" }
+ } }
+[ "http://ш:ш@ш.com:1234/ш?ш=ш#ш" >url ] unit-test
+
{ T{ url
{ protocol "https" }
{ host "www.google.com" }
! See http://factorcode.org/license.txt for BSD license.
USING: accessors ascii assocs combinators
-combinators.short-circuit fry io.pathnames io.sockets
-io.sockets.secure kernel lexer linked-assocs make math
-math.parser multiline namespaces peg.ebnf present sequences
-sequences.generalizations splitting strings strings.parser
-urls.encoding vocabs.loader ;
+combinators.short-circuit fry io.encodings.string
+io.encodings.utf8 io.pathnames io.sockets io.sockets.secure
+kernel lexer linked-assocs make math math.parser multiline
+namespaces peg.ebnf present sequences sequences.generalizations
+splitting strings strings.parser urls.encoding vocabs.loader ;
IN: urls
PRIVATE>
M: string >url
- [ <url> ] dip parse-url 5 firstn {
+ [ <url> ] dip utf8 encode parse-url 5 firstn {
[ >lower >>protocol ]
[
[
: unparse-username-password ( url -- )
dup username>> dup [
- % password>> [ ":" % % ] when* "@" %
+ url-encode % password>> [ ":" % url-encode % ] when* "@" %
] [ 2drop ] if ;
: url-port ( url -- port/f )