GNU bug report logs - #8706
24.0.50; [PATCH] Function to build a URL query-string

Previous Next

Package: emacs;

Reported by: Ian Eure <ian <at> simplegeo.com>

Date: Fri, 20 May 2011 18:40:02 UTC

Severity: wishlist

Tags: patch

Found in version 24.0.50

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ian Eure <ian <at> simplegeo.com>
To: 8706 <at> debbugs.gnu.org
Subject: bug#8706: 24.0.50; [PATCH] Function to build a URL query-string
Date: Fri, 20 May 2011 11:37:45 -0700
This patch adds a url-build-query-string method, which performs the opposite job of url-parse-query-string. I find myself needing this method in many projects, and having it in url-util.el seems beneficial.

--- url-util.el.orig	2011-05-20 11:32:42.000000000 -0700
+++ url-util.el	2011-05-20 11:32:15.000000000 -0700
@@ -281,6 +281,20 @@
 	  (setq retval (cons (list key val) retval)))))
     retval))
 
+;;;###autoload
+(defun url-build-query-string (query)
+  "Build a query-string.
+
+Given a QUERY in the form:
+'((key1 val1)
+  (key2 val2))
+
+This will return a string `key1=val1&key2=val2'. Keys may be strings
+or symbols; if they are symbols, the string name will be used."
+
+  (c-concat-separated
+   (mapcar (lambda (pair) (apply 'format "%s=%s" pair)) query) "&"))
+
 (defun url-unhex (x)
   (if (> x ?9)
       (if (>= x ?a)




This bug report was last modified 13 years and 13 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.