>url dup protocol>> "gopher" = [ not-a-gopher-url ] unless {
[ host>> ]
[ port>> 70 or <inet> binary ]
- [ path>> rest [ "1/" ] when-empty ]
+ [ path>> rest url-encode [ "1/" ] when-empty ]
[ query>> [ assoc>query url-decode "?" glue ] when* ]
} cleave '[
1 minutes input-stream get set-timeout
formatting fry io io.directories io.encodings.binary
io.encodings.string io.encodings.utf8 io.files io.files.info
io.files.types io.pathnames io.servers kernel locals math
-mime.types sequences splitting strings ;
+mime.types sequences splitting strings urls.encoding ;
IN: gopher.server
] [
path prepend-path
server serving-directory>> ?head drop
+ url-encode
] bi
server serving-hostname>>
server insecure>>
: read-gopher-path ( -- path )
readln dup [ "\t\r\n" member? ] find drop [ head ] when*
- trim-tail-separators ;
+ trim-tail-separators url-decode ;
M: gopher-server handle-client*
dup serving-directory>> read-gopher-path append-path