This is an automated email from the ASF dual-hosted git repository.
rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-package-alarms.git
The following commit(s) were added to refs/heads/master by this push:
new 8736ac2 Handle URL params gently (#219)
8736ac2 is described below
commit 8736ac289b9a4a832b484437bc9b0bbbbf7e6632
Author: Nikolay <[email protected]>
AuthorDate: Fri Jun 19 15:37:21 2020 +0300
Handle URL params gently (#219)
Previously url variable has strictly provided "https" protocol, which
totally broke feed if "https" was provided in endpoint variable. Add new
function based on regex to handle both types with or without protocol.
---
action/alarm.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/action/alarm.js b/action/alarm.js
index 5ed5d43..bef5840 100644
--- a/action/alarm.js
+++ b/action/alarm.js
@@ -17,6 +17,13 @@
const common = require('./lib/common');
+function addHTTPS(url) {
+ if (!/^https?\:\/\//.test(url)) {
+ url = "https://" + url;
+ }
+ return url;
+}
+
function main(msg) {
let eventMap = {
@@ -33,8 +40,9 @@ function main(msg) {
var endpoint = msg.apihost;
var webparams = common.createWebParams(msg);
+ var apiHost = addHTTPS(endpoint);
- var url =
`https://${endpoint}/api/v1/web/whisk.system/alarmsWeb/alarmWebAction.http`;
+ var url = `${apiHost}/api/v1/web/whisk.system/alarmsWeb/alarmWebAction`;
if (lifecycleEvent in eventMap) {
var method = eventMap[lifecycleEvent];