unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* url-encode-url: do not add a trailing slash for "bare" URLs (with no file/directory)
@ 2014-03-12 10:19 Bastien
  2014-03-12 13:40 ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2014-03-12 10:19 UTC (permalink / raw)
  To: emacs-devel

[-- 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-03-13 13:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-12 10:19 url-encode-url: do not add a trailing slash for "bare" URLs (with no file/directory) Bastien
2014-03-12 13:40 ` 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).