MCPcopy Create free account
hub / github.com/UI5/webcomponents / validateThemeOrigin

Function validateThemeOrigin

packages/base/src/validateThemeRoot.ts:10–27  ·  view source on GitHub ↗
(origin: string, isSameOrigin: boolean = false)

Source from the content-addressed store, hash-verified

8};
9
10const validateThemeOrigin = (origin: string, isSameOrigin: boolean = false) => {
11 const allowedOrigins = getMetaTagValue("sap-allowed-theme-origins") ?? getMetaTagValue("sap-allowedThemeOrigins"); // Prioritize the new meta tag name
12
13 // If no allowed origins are specified, block.
14 if (!allowedOrigins) {
15 return false;
16 }
17
18 // If it's same-origin (relative URL resolved to current page), allow it when there's any meta tag present
19 // The presence of the meta tag indicates the user wants to use theme roots
20 if (isSameOrigin) {
21 return true;
22 }
23
24 return allowedOrigins.split(",").some(allowedOrigin => {
25 return allowedOrigin === "*" || origin === allowedOrigin.trim();
26 });
27};
28
29const validateThemeRoot = (themeRoot: string) => {
30 let resultUrl;

Callers 1

validateThemeRootFunction · 0.85

Calls 1

getMetaTagValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…