web-manager 3.2.66 → 3.2.68

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.
package/index.js CHANGED
@@ -87,6 +87,8 @@ function Manager() {
87
87
  global: {
88
88
  version: '',
89
89
  url: '',
90
+ functionsUrl: '',
91
+ apiUrl: '',
90
92
  buildTime: 0,
91
93
  cacheBreaker: '',
92
94
  brand: {
@@ -625,7 +627,7 @@ Manager.prototype.init = function(configuration, callback) {
625
627
  self.properties.global.app = configuration.global.app;
626
628
  self.properties.global.version = configuration.global.version;
627
629
  self.properties.global.url = configuration.global.url;
628
- self.properties.global.buildTime = new Date((+configuration.global.buildTime * 1000) || new Date())
630
+ self.properties.global.buildTime = new Date((+configuration.global.buildTime * 1000) || new Date());
629
631
  self.properties.global.cacheBreaker = configuration.global.cacheBreaker;
630
632
 
631
633
  self.properties.global.brand = configuration.global.brand;
@@ -637,6 +639,11 @@ Manager.prototype.init = function(configuration, callback) {
637
639
  self.properties.meta.environment = utilities.get(configuration, 'global.settings.debug.environment', self.properties.meta.environment);
638
640
  self.properties.page.queryString = new URLSearchParams(window.location.search);
639
641
 
642
+ // set global properties
643
+ self.properties.global.apiUrl = getApiUrl(self.properties.global.url);
644
+ self.properties.global.functionsUrl = 'https://us-central1-' + self.properties.options.libraries.firebase_app.config.projectId + '.cloudfunctions.net';
645
+
646
+ // set page properties
640
647
  var pagePathname = window.location.pathname;
641
648
  var redirect = false;
642
649
 
@@ -1804,6 +1811,25 @@ Manager.prototype.isDevelopment = function () {
1804
1811
  // }
1805
1812
  // }
1806
1813
 
1814
+ function getApiUrl(url) {
1815
+ // Set API url
1816
+ var globalUrl = new URL(url);
1817
+ var hostnameParts = globalUrl.hostname.split('.');
1818
+
1819
+ // Check if subdomain exists
1820
+ if (hostnameParts.length > 2) {
1821
+ hostnameParts[0] = 'api';
1822
+ } else {
1823
+ hostnameParts.unshift('api');
1824
+ }
1825
+
1826
+ // Set hostname
1827
+ globalUrl.hostname = hostnameParts.join('.');
1828
+
1829
+ // Return new URL
1830
+ return globalUrl.toString();
1831
+ }
1832
+
1807
1833
 
1808
1834
  /**
1809
1835
  * HELPERS
package/lib/account.js CHANGED
@@ -70,7 +70,7 @@ Account.prototype.delete = function (options) {
70
70
  } else {
71
71
  user.getIdToken(false)
72
72
  .then(function(token) {
73
- fetch('https://us-central1-' + self.utilities.get(self.Manager, 'properties.options.libraries.firebase_app.config.projectId', 'unknown') + '.cloudfunctions.net/bm_api', {
73
+ fetch(self.Manager.properties.global.functionsUrl + '/bm_api', {
74
74
  // fetch('http://localhost:5001/optiic-api/us-central1/bm_api', {
75
75
  method: 'POST',
76
76
  headers: { 'Content-Type': 'application/json' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.66",
3
+ "version": "3.2.68",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "index.js",
6
6
  "scripts": {