From 441655ac1e504309424bc69b701c488937830899 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Fri, 5 Mar 2021 15:11:13 +0100 Subject: [PATCH] Generate proxy URLs with complex path --- src/utils.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/utils.js b/src/utils.js index b7d3672..191bb8c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -const generateProxyURL = (type, url, opts) => { +const generateProxyURL = (type, urlElements, opts) => { if (!opts || !opts.doipProxyHostname) { return null } @@ -21,9 +21,16 @@ const generateProxyURL = (type, url, opts) => { if (type == 'xmpp') { addParam += '/DESC' } + + if (!Array.isArray(urlElements)) { + urlElements = [urlElements] + } + + urlElements.map((x) => { encodeURIComponent(x) }) + return `https://${ opts.doipProxyHostname - }/api/1/get/${type}/${encodeURIComponent(url)}${addParam}` + }/api/1/get/${type}/${urlElements.join('/')}${addParam}` } const generateClaim = (fingerprint, format) => {