[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [flashproxy/master] Factor out build_query_string.
commit 7ec7275f700f1a955bda23c3d54a145b4e9feca7
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date: Tue Feb 5 15:30:40 2013 -0800
Factor out build_query_string.
---
proxy/flashproxy.js | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/proxy/flashproxy.js b/proxy/flashproxy.js
index 8cf086f..c4ffad3 100644
--- a/proxy/flashproxy.js
+++ b/proxy/flashproxy.js
@@ -175,6 +175,15 @@ function parse_query_string(qs) {
return result;
}
+/* params is a list of (key, value) 2-tuples. */
+function build_query_string(params) {
+ var parts = [];
+ for (var i = 0; i < params.length; i++) {
+ parts.push(encodeURIComponent(params[i][0]) + "=" + encodeURIComponent(params[i][1]));
+ }
+ return parts.join("&");
+}
+
var DEFAULT_PORTS = {
http: 80,
https: 443
@@ -218,11 +227,7 @@ function build_url(scheme, host, port, path, params) {
if (params !== undefined) {
parts.push("?");
- for (var i = 0; i < params.length; i++) {
- if (i > 0)
- parts.push("&");
- parts.push(encodeURIComponent(params[i][0]) + "=" + encodeURIComponent(params[i][1]));
- }
+ parts.push(build_query_string(params));
}
return parts.join("");
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits