bug#60528: uri->string swallows mandatory slashes

<[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <Y7U0nnNemAVKa4/[email protected]>
On Tue, Jan 03, 2023 at 09:00:48PM +0100, Liliana Marie Prikler wrote:
> Hi folks,
> 
> Below some unexpected behaviour observed in Guile 3.0.8, but it also
> dates back to 2.2.7 and possibly earlier versions.
> 
> scheme@(guile-user)> ,use (web uri)
> scheme@(guile-user)> (string->uri "file:///home") 
> $1 = #<<uri> scheme: file userinfo: #f host: #f port: #f path: "/home"
> query: #f fragment: #f>
> scheme@(guile-user)> (uri->string $1)
> $2 = "file:/home"

This looks strange, but not necessarily wrong. "file:///home" means
"empty authority", equivalent to "localhost" whereas "file:/home" means
"no authority". I'd expect the library to keep those two separate.
 
> scheme@(guile-user)> (uri->string (build-uri 'file #:host "" #:path
> "/home")) 
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> Throw to key `uri-error' with args `("Expected valid host: ~s" (""))'.

Note that "no host" is not the empty string, but #f:

> scheme@(guile-user)> (uri->string (build-uri 'file #:host "" #:path
> "/home")) 

  scheme@(guile-user)> (uri->string (build-uri 'file #:host #f #:path "/home"))
  $6 = "file:/home"

So it is consistent, albeit (to me) surprising. I'd have expect
your `$2' above to be "file:///home", with three slashes.

Cheers
-- 
t
signature.asc (application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE-----

iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCY7U0lgAKCRAFyCz1etHa
RqqhAJsH7LGGB2VsUPQNQC+x0cFBlGOSYACfTdumx/6k/kLE3ppjzPBn0XcrgNU=
=+GQQ
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.