@constructor-io/constructorio-client-javascript 2.43.0 → 2.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -107,10 +107,11 @@ var ConstructorIO = /*#__PURE__*/function () {
107
107
  throw new Error('clientId is a required user parameter of type string');
108
108
  }
109
109
  }
110
+ var normalizedServiceUrl = serviceUrl && serviceUrl.replace(/\/$/, '');
110
111
  this.options = {
111
112
  apiKey: apiKey,
112
113
  version: versionFromOptions || versionFromGlobal || computePackageVersion(),
113
- serviceUrl: serviceUrl && serviceUrl.replace(/\/$/, '') || 'https://ac.cnstrc.com',
114
+ serviceUrl: helpers.addHTTPSToString(normalizedServiceUrl) || 'https://ac.cnstrc.com',
114
115
  quizzesServiceUrl: quizzesServiceUrl && quizzesServiceUrl.replace(/\/$/, '') || 'https://quizzes.cnstrc.com',
115
116
  sessionId: sessionId || session_id,
116
117
  clientId: clientId || client_id,
@@ -220,6 +220,21 @@ var utils = {
220
220
  // do nothing
221
221
  }
222
222
  return obfuscatedUrl;
223
+ },
224
+ addHTTPSToString: function addHTTPSToString(url) {
225
+ if (typeof url !== 'string') {
226
+ return null;
227
+ }
228
+ var doesUrlIncludeHTTPS = url.startsWith('https://');
229
+ var doesUrlStartWithHTTP = url.startsWith('http://');
230
+ if (!doesUrlIncludeHTTPS && doesUrlStartWithHTTP) {
231
+ return url.replace('http', 'https');
232
+ }
233
+ if (!doesUrlStartWithHTTP && !doesUrlIncludeHTTPS) {
234
+ var urlWithHttps = "https://".concat(url);
235
+ return urlWithHttps;
236
+ }
237
+ return url;
223
238
  }
224
239
  };
225
240
  module.exports = utils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.43.0",
3
+ "version": "2.44.0",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "types": "lib/types/index.d.ts",