(origin: string, isSameOrigin: boolean = false)
| 8 | }; |
| 9 | |
| 10 | const 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 | |
| 29 | const validateThemeRoot = (themeRoot: string) => { |
| 30 | let resultUrl; |
no test coverage detected
searching dependent graphs…