ensure-port outputs a new URL instead of mutating its input

db4
Slava Pestov 2009-04-01 22:05:12 -05:00
parent 1b0c301005
commit 318da06a71
2 changed files with 4 additions and 5 deletions

View File

@ -65,9 +65,8 @@ HELP: derive-url
} ; } ;
HELP: ensure-port HELP: ensure-port
{ $values { "url" url } } { $values { "url" url } { "url'" url } }
{ $description "If the URL does not specify a port number, fill in the default for the URL's protocol. If the protocol is unknown, the port number is not changed." } { $description "If the URL does not specify a port number, create a new URL which is equal except the port number is set to the default for the URL's protocol. If the protocol is unknown, outputs an exact copy of the input URL." }
{ $side-effects "url" }
{ $examples { $examples
{ $example { $example
"USING: accessors prettyprint urls ;" "USING: accessors prettyprint urls ;"

View File

@ -175,8 +175,8 @@ PRIVATE>
] [ protocol>> ] bi ] [ protocol>> ] bi
secure-protocol? [ >secure-addr ] when ; secure-protocol? [ >secure-addr ] when ;
: ensure-port ( url -- url ) : ensure-port ( url -- url' )
dup protocol>> '[ _ protocol-port or ] change-port ; clone dup protocol>> '[ _ protocol-port or ] change-port ;
! Literal syntax ! Literal syntax
SYNTAX: URL" lexer get skip-blank parse-string >url parsed ; SYNTAX: URL" lexer get skip-blank parse-string >url parsed ;