From dcd179d20084435d6b41ff1c10c8fb030ac063f9 Mon Sep 17 00:00:00 2001 From: Jon Wexler Date: Tue, 24 Apr 2018 18:32:58 -0400 Subject: [PATCH 1/4] adds change for proxy url --- index.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index faa106e..44f90dc 100644 --- a/index.js +++ b/index.js @@ -226,11 +226,26 @@ GiphyAPI.prototype = { }); } - var httpOptions = { - request: { + var proxy = options.query.proxy, + var request; + + if (proxy) { + request = { + host: proxy, + path: (this.https ? "https" : "http" )+ "://" + API_HOSTNAME + API_BASE_PATH + options.api + endpoint + query, + headers: { + Host: API_HOSTNAME + } + } + } else { + request = { host: API_HOSTNAME, path: API_BASE_PATH + options.api + endpoint + query - }, + } + } + + var httpOptions = { + request: request, https: this.https, timeout: this.timeout, fmt: options.query && options.query.fmt From d97538079d909105312d4f752c08c4c8749a480d Mon Sep 17 00:00:00 2001 From: Jon Wexler Date: Tue, 24 Apr 2018 18:35:32 -0400 Subject: [PATCH 2/4] changes for options https --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 44f90dc..1c4e5e4 100644 --- a/index.js +++ b/index.js @@ -232,7 +232,7 @@ GiphyAPI.prototype = { if (proxy) { request = { host: proxy, - path: (this.https ? "https" : "http" )+ "://" + API_HOSTNAME + API_BASE_PATH + options.api + endpoint + query, + path: (options.query.https ? "https" : "http") + "://" + API_HOSTNAME + API_BASE_PATH + options.api + endpoint + query, headers: { Host: API_HOSTNAME } From 58bcb72d39a6e3de5b74655fcf923ef1a9dcf66f Mon Sep 17 00:00:00 2001 From: Jon Wexler Date: Tue, 24 Apr 2018 18:57:31 -0400 Subject: [PATCH 3/4] move request var --- index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 1c4e5e4..fd58513 100644 --- a/index.js +++ b/index.js @@ -227,10 +227,9 @@ GiphyAPI.prototype = { } var proxy = options.query.proxy, - var request; - + if (proxy) { - request = { + var request = { host: proxy, path: (options.query.https ? "https" : "http") + "://" + API_HOSTNAME + API_BASE_PATH + options.api + endpoint + query, headers: { @@ -238,7 +237,7 @@ GiphyAPI.prototype = { } } } else { - request = { + var request = { host: API_HOSTNAME, path: API_BASE_PATH + options.api + endpoint + query } From da05ca78b1ac1516d1710c7f0203c6246f24f5bf Mon Sep 17 00:00:00 2001 From: Jon Wexler Date: Tue, 24 Apr 2018 19:00:01 -0400 Subject: [PATCH 4/4] move request var --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index fd58513..9e46d53 100644 --- a/index.js +++ b/index.js @@ -226,10 +226,11 @@ GiphyAPI.prototype = { }); } - var proxy = options.query.proxy, - + var proxy = options.query.proxy; + var request; + if (proxy) { - var request = { + request = { host: proxy, path: (options.query.https ? "https" : "http") + "://" + API_HOSTNAME + API_BASE_PATH + options.api + endpoint + query, headers: { @@ -237,7 +238,7 @@ GiphyAPI.prototype = { } } } else { - var request = { + request = { host: API_HOSTNAME, path: API_BASE_PATH + options.api + endpoint + query }