From 161d64d427fd87dc0856e18e310fda2b89f33c6d Mon Sep 17 00:00:00 2001 From: pixelistik Date: Wed, 5 Mar 2014 20:28:11 +0100 Subject: [PATCH] HTTP package: fix URL building If a URL has no query string, the HTTP package added the string 'undefined' to the end of the URL. This fix reduces the failing assertions in the existing tests for the HTTP package from 8 to 1 (using InDesign CS6 as the environment). This fix is similar to pull request #23. --- core-packages/http/lib/index.jsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core-packages/http/lib/index.jsx b/core-packages/http/lib/index.jsx index fa19f7f..f5cc9a6 100644 --- a/core-packages/http/lib/index.jsx +++ b/core-packages/http/lib/index.jsx @@ -347,7 +347,12 @@ function HTTPRequest (method, url, timeout) { // request line var head = []; var url = this.url(); - var path = url.pathname + url.search; + var path; + if (url.search) { + path = url.pathname + url.search; + } else { + path = url.pathname; + } var request_line = "{} {} HTTP/1.1".format(this.method(), path || "/"); head.push(request_line); // headers to string (kv) form @@ -575,4 +580,4 @@ function HTTPResponse (method, encoding, request) { * However, before we could consider this optimization, we'd need to optimize the ByteString class, * and in particular make it possible and fast to concatenate / add in string data to an existing * byte class. Then we could process the data parts we receive on the fly rather than post-hoc. - */ \ No newline at end of file + */