All files / config/app app.config.js

100% Statements 12/12
100% Branches 6/6
100% Functions 4/4
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55    7x                   3x               4x 2x   4x 4x 2x   4x               3x 2x   3x           7x                    
/** @param {import('../types').ConfigImports} $inject */
function appConfig_injector($inject) {
  const { APP_SDK_BASE } = $inject;
  /** @type {URL} */
  let sdkBase;
 
  /**
   * For local testing. This does not need to be documented, and customers should not
   * use this.
   * @type {import('../types').AppConfig['setSDKBase']}
   */
  function setSDKBase(newBase) {
    sdkBase = new URL(newBase);
  }
 
  /**
   * @type {import('../types').AppConfig['getSDKBase']}
   */
  function getSDKBase() {
    // Always fall back to default if the sdk base gets clobbered
    if (!sdkBase) {
      sdkBase = new URL(APP_SDK_BASE);
    }
    let base = sdkBase.toString();
    if (base.charAt(base.length - 1) === '/') {
      base = base.substring(0, base.length - 1);
    }
    return base;
  }
 
  /**
   * @type {import('../types').AppConfig['getFrameOrigin']}
   */
  function getFrameOrigin() {
    // Always fall back to default if the sdk base gets clobbered
    if (!sdkBase) {
      sdkBase = new URL(APP_SDK_BASE);
    }
    return sdkBase.origin;
  }
 
  /**
   * @type {import('../types').AppConfig}
   */
  return {
    // sdkBase: sdkBase.toString(),
    // frameOrigin: sdkBase.origin,
    setSDKBase,
    getSDKBase,
    getFrameOrigin,
  };
}
 
export { appConfig_injector };