From 332972633bb898212a76e01001e0a2ee44217065 Mon Sep 17 00:00:00 2001 From: Alexei Ledenev Date: Mon, 23 Apr 2018 12:15:49 +0300 Subject: [PATCH] use url encoding for event-uri passed in path/query for REST API (#183) * URI encode eventURI * URI encode eventURI - version update * merge package.json from master --- lib/logic/api/trigger.js | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/logic/api/trigger.js b/lib/logic/api/trigger.js index 746cadedb..c9dc6d475 100644 --- a/lib/logic/api/trigger.js +++ b/lib/logic/api/trigger.js @@ -100,7 +100,7 @@ const getPipelineTriggers = async (pipeline) => { const getEventTriggers = async (event) => { const options = { - url: `/api/hermes/triggers/event/${event.replace('/', '_slash_')}`, + url: `/api/hermes/triggers/event/${encodeURIComponent(event)}`, method: 'GET', }; @@ -117,7 +117,7 @@ const getEventTriggers = async (event) => { const createTrigger = async (event, pipeline, filters) => { const options = { - url: `/api/hermes/triggers/${event.replace('/', '_slash_')}/${pipeline}`, + url: `/api/hermes/triggers/${encodeURIComponent(event)}/${pipeline}`, method: 'POST', body: { filters, @@ -129,7 +129,7 @@ const createTrigger = async (event, pipeline, filters) => { const deleteTrigger = async (event, pipeline) => { const options = { - url: `api/hermes/triggers/${event.replace('/', '_slash_')}/${pipeline}`, + url: `api/hermes/triggers/${encodeURIComponent(event)}/${pipeline}`, method: 'DELETE', }; @@ -140,7 +140,7 @@ const deleteTrigger = async (event, pipeline) => { const getEvent = async (event) => { const options = { - url: `/api/hermes/events/${event.replace('/', '_slash_')}`, + url: `/api/hermes/events/${encodeURIComponent(event)}`, method: 'GET', }; @@ -151,7 +151,7 @@ const getEvent = async (event) => { const getEvents = async (type, kind, filter, pub) => { const options = { - url: `/api/hermes/events/?type=${type}&kind=${kind}&filter=${filter.replace('/', '_slash_')}&public=${pub}`, + url: `/api/hermes/events/?type=${type}&kind=${kind}&filter=${encodeURIComponent(filter)}&public=${pub}`, method: 'GET', }; @@ -181,7 +181,7 @@ const createEvent = async (type, kind, secret, values, context, pub) => { const deleteEvent = async (event, context) => { const options = { - url: `/api/hermes/events/${event.replace('/', '_slash_')}/${context}`, + url: `/api/hermes/events/${encodeURIComponent(event)}/${context}`, method: 'DELETE', }; diff --git a/package.json b/package.json index 4a63c5d4b..d4face56b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.8.44", + "version": "0.8.45", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,