From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bastien Newsgroups: gmane.emacs.devel 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 Message-ID: <87k3bzhg81.fsf@bzg.ath.cx> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1394619572 25930 80.91.229.3 (12 Mar 2014 10:19:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Mar 2014 10:19:32 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 12 11:19:41 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WNgGC-0007EC-Md for ged-emacs-devel@m.gmane.org; Wed, 12 Mar 2014 11:19:40 +0100 Original-Received: from localhost ([::1]:59674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNgGC-0007om-8A for ged-emacs-devel@m.gmane.org; Wed, 12 Mar 2014 06:19:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNgG4-0007oS-MU for emacs-devel@gnu.org; Wed, 12 Mar 2014 06:19:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNgFy-0000Gv-3V for emacs-devel@gnu.org; Wed, 12 Mar 2014 06:19:32 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:52593) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNgFx-0000GU-T4 for emacs-devel@gnu.org; Wed, 12 Mar 2014 06:19:26 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WNgFu-0006xj-Ob for emacs-devel@gnu.org; Wed, 12 Mar 2014 11:19:22 +0100 Original-Received: from amontsouris-651-1-244-140.w92-163.abo.wanadoo.fr ([92.163.19.140]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Mar 2014 11:19:22 +0100 Original-Received: from bzg by amontsouris-651-1-244-140.w92-163.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Mar 2014 11:19:22 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 61 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: amontsouris-651-1-244-140.w92-163.abo.wanadoo.fr User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:qVPR2PghEVXZa0v0jNjAyGvTSbg= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:170290 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=url-parse.el.patch === 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) --=-=-= Content-Type: text/plain -- Bastien --=-=-=--