[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: url-encode-url: do not add a trailing slash for "bare" URLs (with no

From: David Caldwell
Subject: Re: url-encode-url: do not add a trailing slash for "bare" URLs (with no file/directory)
Date: Wed, 12 Mar 2014 22:28:11 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Bastien <bzg <at> gnu.org> writes:

> Hi Stefan,
> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> >> The following trivial patch changes this.
> >
> > I'm no expert on URL conventions, but it looks OK to me, tho maybe the /
> > is needed when there's a fragment.

The relevant RFC here is 3986 (https://tools.ietf.org/html/rfc3986). Section
3 (https://tools.ietf.org/html/rfc3986#page-16) talks about the syntax.

> With the patch we have
> (url-encode-url "http://www.gnu.org#";)
>   => http://www.gnu.org
> instead of
> (url-encode-url "http://www.gnu.org#";)
>   => http://www.gnu.org/
> (no trailing slash with the patch), but I don't think
> http://www.gnu.org# is correct anyway.

That appears to be allowed by my reading of the RFC. The path is allowed to
be empty, so http://www.gnu.org#something and http://www.gnu.org?some-query
would both be valid. That being said, a quick test of curl shows that it
doesn't like # right on the end:

  $ curl 'http://www.gnu.org#someting'
  curl: (6) Could not resolve host: www.gnu.org#something

Firefox handles the same URL correctly.

That being said, there's no point at all to elide the / at the root. With
other paths there's a difference at the http level:

   http://gnu.org/emacs/ -> http command "GET /emacs/"
   http://gnu.org/emacs  -> http command "GET /emacs"

But the root one doesn't change:

   http://gnu.org/  -> http command "GET /"
   http://gnu.org   -> http command "GET /"

…since it's not valid http to just say "GET".


reply via email to

[Prev in Thread] Current Thread [Next in Thread]