[racket-dev] Potential bug in path->url

From: Philippe Mechaï (philippe.mechai at gmail.com)
Date: Tue Nov 6 17:43:58 EST 2012

Hi,

I think there is a bug in the path->url function (from net/url).

> (url->string (path->url "/tmp"))
"file:///tmp"
> (url->string (path->url "/tmp/"))
"file:///tmp"

As you can see the resulting URL is the same even if the path is a
directory path.
I believe that in the second case the URL should be "file:///tmp/".

This lead to an unexpected behaviour when using the result of path->url
with combine-url/relative:

> (url->string (combine-url/relative (path->url "/tmp/") "foo.txt"))
"file:///foo.txt"

I've made a fix and created the pull request #166 on GitHub (
https://github.com/plt/racket/pull/166)

Could you please merge this change ?

Also, it should be noted that the path->url and url->path are not symmetric
as one could expect.
Before my modification:
  (url->path (path->url "/tmp/")) => #<path:/tmp>
After:
  (url->path (path->url "/tmp/")) => #<path:/tmp/.>

I don't think it is a real problem but I thought it was worth mentioning.

Regards,
Philippe Mechaï
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20121106/c8db23c5/attachment.html>

Posted on the dev mailing list.