all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bastien <bzg@gnu.org>
To: emacs-devel@gnu.org
Subject: url-encode-url: do not add a trailing slash for "bare" URLs (with no file/directory)
Date: Wed, 12 Mar 2014 11:19:10 +0100	[thread overview]
Message-ID: <87k3bzhg81.fsf@bzg.ath.cx> (raw)

[-- Attachment #1: Type: text/plain, Size: 711 bytes --]

For now url-encode-url does this:

(url-encode-url "http://www.gnu.org")
   => http://www.gnu.org/

I suggest to not add the trailing slash:

(url-encode-url "http://www.gnu.org")
   => http://www.gnu.org

Adding a trailing slash is only recommended when there is a directory
after the domain name, like in "http://www.gnu.org/software", which
should be written "http://www.gnu.org/software/".

For now url-encode-url is right about *not* adding the trailing slash
in the above case (as this would lead to too many false positives) but
wrong in adding it for http://www.gnu.org, as this disambiguation is
not needed.

Am I missing cases when it is definitely needed?

The following trivial patch changes this.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: url-parse.el.patch --]
[-- Type: text/x-diff, Size: 548 bytes --]

=== modified file 'lisp/url/url-parse.el'
*** lisp/url/url-parse.el	2014-01-01 07:43:34 +0000
--- lisp/url/url-parse.el	2014-03-12 10:08:48 +0000
***************
*** 94,100 ****
  			"@"))
  	    host
  	    (if port (format ":%d" (url-port urlobj)))
! 	    (or file "/")
  	    (if frag (concat "#" frag)))))
  
  (defun url-recreate-url-attributes (urlobj)
--- 94,100 ----
  			"@"))
  	    host
  	    (if port (format ":%d" (url-port urlobj)))
! 	    file
  	    (if frag (concat "#" frag)))))
  
  (defun url-recreate-url-attributes (urlobj)


[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

             reply	other threads:[~2014-03-12 10:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-12 10:19 Bastien [this message]
2014-03-12 13:40 ` url-encode-url: do not add a trailing slash for "bare" URLs (with no file/directory) Stefan Monnier
2014-03-12 14:05   ` Tim Visher
2014-03-12 14:42   ` Bastien
2014-03-12 22:28     ` David Caldwell
2014-03-13  8:06       ` Bastien
2014-03-13 13:12         ` Stefan Monnier
2014-03-13 13:50           ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k3bzhg81.fsf@bzg.ath.cx \
    --to=bzg@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.