PageSourceSearch

https://www.westpac.com.au/scripts/disclaimer-config.js

js westpac.com.au collected 2026-09-24 08:29:46 UTC 2,384 bytes, 62 lines download raw bytes

1import { getPlaceholderValue } from './utility/placeholder-cache.js';
2
3export const DEFAULT_DISCLAIMER_ROOT = '/content/dam/westpac/au/cf/disclaimers';
4export const DEFAULT_SITE_CONTENT_ROOT = '/content/westpac/au';
5export const DISCLAIMER_ENDPOINT = '/bin/disc';
6export const PLACEHOLDERS_SHEET_NAME = 'Environment Variables';
7export const AEM_ASSETS_DOMAIN_KEY = 'aem-assets-domain';
8export const DISCLAIMER_ROOT_KEY = 'disclaimer-dam-path-prefix';
9export const SITE_CONTENT_ROOT_KEY = 'site-content-root';
10
11function normalizeConfiguredRoot(value, defaultValue, requiredPrefix) {
12  if (typeof value !== 'string') return defaultValue;
13
14  let normalizedValue = value.trim();
15  while (normalizedValue.endsWith('/')) {
16    normalizedValue = normalizedValue.slice(0, -1);
17  }
18  const hasRequiredPrefix = normalizedValue.startsWith(`${requiredPrefix}/`);
19  const hasUnsafeCharacters = /[%\\?#]/.test(normalizedValue);
20  const segments = normalizedValue.split('/').filter(Boolean);
21  const hasSafeSegments = segments.every((segment) => {
22    const isRelativeSegment = segment !== '.' && segment !== '..';
23    const hasSafeCharacters = /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(segment);
24    return isRelativeSegment && hasSafeCharacters;
25  });
26
27  if (!normalizedValue || !hasRequiredPrefix || hasUnsafeCharacters || !hasSafeSegments) {
28    return defaultValue;
29  }
30
31  return normalizedValue;
32}
33
34export async function resolveDisclaimerConfig(options = {}) {
35  const { getPlaceholder = getPlaceholderValue, location = window.location } = options;
36  const configuredValues = await Promise.all([
37    getPlaceholder(PLACEHOLDERS_SHEET_NAME, AEM_ASSETS_DOMAIN_KEY),
38    getPlaceholder(PLACEHOLDERS_SHEET_NAME, DISCLAIMER_ROOT_KEY),
39    getPlaceholder(PLACEHOLDERS_SHEET_NAME, SITE_CONTENT_ROOT_KEY),
40  ]);
41  const configuredAssetsHost = configuredValues[0];
42  const configuredDisclaimerRoot = configuredValues[1];
43  const configuredSiteContentRoot = configuredValues[2];
44
45  const assetsHost = location.hostname.includes('.adobeaemcloud.com')
46    ? location.origin
47    : configuredAssetsHost;
48
49  return {
50    assetsHost,
51    disclaimerRoot: normalizeConfiguredRoot(
52      configuredDisclaimerRoot,
53      DEFAULT_DISCLAIMER_ROOT,
54      '/content/dam',
55    ),
56    siteContentRoot: normalizeConfiguredRoot(
57      configuredSiteContentRoot,
58      DEFAULT_SITE_CONTENT_ROOT,
59      '/content',
60    ),
61  };
62}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.