@nuskin/ns-util 4.4.0 → 4.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-util",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "baseURL": "/",
5
5
  "main": "src/util.js",
6
6
  "scripts": {
@@ -1,4 +1,4 @@
1
- import {getCachedConfigField} from "@nuskin/configuration-sdk";
1
+ import {getConfiguration} from "@nuskin/configuration-sdk";
2
2
  import URLService from "./urlService";
3
3
 
4
4
  const GOOGLE_MAPS_API_URL = "https://maps.googleapis.com/maps/api/js";
@@ -29,18 +29,24 @@ export default {
29
29
  function load() {
30
30
  if (!apiLoadingPromise) {
31
31
  apiLoadingPromise = new Promise((resolve, reject) => {
32
- const $script = document.createElement("script");
33
- $script.setAttribute("type", "text/javascript");
34
- $script.setAttribute("async", "true");
35
- $script.onload = () => resolve();
36
- $script.onerror = () =>
37
- reject(new Error("Google Maps API script failed to load"));
38
- const src = `${GOOGLE_MAPS_API_URL}?${URLService.toQueryString({
39
- key: getCachedConfigField('googleMapsApiKey'),
40
- libraries: ["places"]
41
- })}`;
42
- $script.setAttribute("src", src);
43
- document.body.appendChild($script);
32
+ getConfiguration(['Url'])
33
+ .then(({Url: urlCfg}) => {
34
+ const $script = document.createElement("script");
35
+ $script.setAttribute("type", "text/javascript");
36
+ $script.setAttribute("async", "true");
37
+ $script.onload = () => resolve();
38
+ $script.onerror = () =>
39
+ reject(new Error("Google Maps API script failed to load"));
40
+ const src = `${GOOGLE_MAPS_API_URL}?${URLService.toQueryString({
41
+ key: urlCfg.googleMapsApiKey,
42
+ libraries: ["places"]
43
+ })}`;
44
+ $script.setAttribute("src", src);
45
+ document.body.appendChild($script);
46
+ })
47
+ .catch((err) => {
48
+ reject(new Error(err));
49
+ });
44
50
  });
45
51
  }
46
52
  return apiLoadingPromise;
@@ -12,7 +12,9 @@ const CONTEXT_WHITELIST = [
12
12
  /\/static\//, // all static apps
13
13
  /\/exclusive-offer\./, // leader preview
14
14
  /\/catalog\//, // catalog/PDP3
15
- /\w+\.(test)?\.?nuskin\.io/ // AEM Feature Branch
15
+ /\w+\.(test)?\.?nuskin\.io/, // AEM Feature Branch
16
+ /\/[a-z]{2}\/[a-z]{2}\//, // Any Equinox Page (should be redirected from /us/en/xxxxxx)
17
+ /\/[a-z]{2}\/[a-z]{2}$/ // Equinox homepage (should be redirected from /us/en)
16
18
  ];
17
19
  /**
18
20
  *