urls: allow pathnames to convert >url.

db4
John Benediktsson 2012-10-22 20:16:19 -07:00
parent 34908c8446
commit dd6d1e50cf
1 changed files with 8 additions and 7 deletions

View File

@ -1,10 +1,11 @@
! Copyright (C) 2008, 2011 Slava Pestov. ! Copyright (C) 2008, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel ascii combinators combinators.short-circuit
sequences splitting fry namespaces make assocs arrays strings USING: accessors arrays assocs combinators fry hashtables
io.sockets io.encodings.string io.encodings.utf8 math io.pathnames io.sockets kernel lexer make math.parser
math.parser accessors parser strings.parser lexer namespaces peg.ebnf present sequences splitting strings
hashtables present peg.ebnf urls.encoding ; strings.parser urls.encoding vocabs.loader ;
IN: urls IN: urls
TUPLE: url protocol username password host port path query anchor ; TUPLE: url protocol username password host port path query anchor ;
@ -84,6 +85,8 @@ M: string >url
} cleave } cleave
dup host>> [ [ "/" or ] change-path ] when ; dup host>> [ [ "/" or ] change-path ] when ;
M: pathname >url string>> >url ;
: protocol-port ( protocol -- port ) : protocol-port ( protocol -- port )
{ {
{ "http" [ 80 ] } { "http" [ 80 ] }
@ -192,7 +195,5 @@ PRIVATE>
! Literal syntax ! Literal syntax
SYNTAX: URL" lexer get skip-blank parse-string >url suffix! ; SYNTAX: URL" lexer get skip-blank parse-string >url suffix! ;
USE: vocabs.loader
{ "urls" "prettyprint" } "urls.prettyprint" require-when { "urls" "prettyprint" } "urls.prettyprint" require-when
{ "urls" "io.sockets.secure" } "urls.secure" require-when { "urls" "io.sockets.secure" } "urls.secure" require-when