@ui5/webcomponents-base 2.14.0 → 2.14.1
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/CHANGELOG.md +12 -0
- package/dist/.tsbuildinfobuild +1 -1
- package/dist/InitialConfiguration.js +1 -9
- package/dist/InitialConfiguration.js.map +1 -1
- package/dist/config/ThemeRoot.js +12 -7
- package/dist/config/ThemeRoot.js.map +1 -1
- package/dist/custom-elements-internal.json +42 -42
- package/dist/custom-elements.json +42 -42
- package/dist/generated/VersionInfo.js +3 -3
- package/dist/generated/VersionInfo.js.map +1 -1
- package/dist/prod/InitialConfiguration.js +1 -1
- package/dist/prod/InitialConfiguration.js.map +3 -3
- package/dist/prod/config/ThemeRoot.js +1 -1
- package/dist/prod/config/ThemeRoot.js.map +3 -3
- package/dist/prod/generated/VersionInfo.js +1 -1
- package/dist/prod/generated/VersionInfo.js.map +1 -1
- package/dist/prod/validateThemeRoot.js +1 -1
- package/dist/prod/validateThemeRoot.js.map +3 -3
- package/dist/validateThemeRoot.js +18 -11
- package/dist/validateThemeRoot.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/config/ThemeRoot.ts"],
|
|
4
|
-
"sourcesContent": ["import createLinkInHead from \"../util/createLinkInHead.js\";\nimport validateThemeRoot from \"../validateThemeRoot.js\";\nimport { getThemeRoot as getConfiguredThemeRoot } from \"../InitialConfiguration.js\";\nimport { getTheme } from \"./Theme.js\";\nimport { attachConfigurationReset } from \"./ConfigurationReset.js\";\n\nlet currThemeRoot: string | undefined;\n\nattachConfigurationReset(() => {\n\tcurrThemeRoot = undefined;\n});\n\n/**\n * Returns the current theme root.\n *\n * @public\n * @since 1.14.0\n * @returns { string } the current theme root\n */\nconst getThemeRoot = (): string | undefined => {\n\tif (currThemeRoot === undefined) {\n\t\tcurrThemeRoot = getConfiguredThemeRoot();\n\t}\n\n\treturn currThemeRoot;\n};\n\n/**\n * Sets theme root for the current theme.\n * When set, the framework will validate the theme root and fetch the theme styles (CSS variables) from this location.\n *\n * **Note:** The feature is specific to custom themes, created with the `UI Theme Designer`.\n * The provided theme root is used only as a base to construct the actual location of the theme styles: `{themeRoot}/.../css_variables.css`.\n *\n * **Note:** Certain security restrictions will apply before fetching the theme assets.\n * Absolute URLs to a different origin than the current page will result in using the current page as an origin.\n *\n * **Important:** To use this feature you must explicitly allow specific origins by using <meta name=\"sap-allowed-theme-origins\" content=\"https://my-example-host.com/\"> tag inside the <head> of the page.\n * Failing to do so will result in a warning in the console and the theme root will not be set.\n *\n * @public\n * @since 1.14.0\n * @param { string } themeRoot the new theme root\n * @returns { Promise<void> }\n */\nconst setThemeRoot = (themeRoot: string): Promise<void> | undefined => {\n\tif (currThemeRoot === themeRoot) {\n\t\treturn;\n\t}\n\n\tcurrThemeRoot = themeRoot;\n\n\
|
|
5
|
-
"mappings": "aAAA,OAAOA,MAAsB,8BAC7B,OAAOC,MAAuB,0BAC9B,OAAS,gBAAgBC,MAA8B,6BACvD,OAAS,YAAAC,MAAgB,aACzB,OAAS,4BAAAC,MAAgC,0BAEzC,IAAIC,EAEJD,EAAyB,IAAM,CAC9BC,EAAgB,MACjB,CAAC,EASD,MAAMC,EAAe,KAChBD,IAAkB,SACrBA,EAAgBH,EAAuB,GAGjCG,GAqBFE,EAAgBC,GAAiD,CACtE,GAAIH,IAAkBG,
|
|
6
|
-
"names": ["createLinkInHead", "validateThemeRoot", "getConfiguredThemeRoot", "getTheme", "attachConfigurationReset", "currThemeRoot", "getThemeRoot", "setThemeRoot", "themeRoot", "attachCustomThemeStylesToHead", "formatThemeLink", "theme", "link"]
|
|
4
|
+
"sourcesContent": ["import createLinkInHead from \"../util/createLinkInHead.js\";\nimport validateThemeRoot from \"../validateThemeRoot.js\";\nimport { getThemeRoot as getConfiguredThemeRoot } from \"../InitialConfiguration.js\";\nimport { getTheme } from \"./Theme.js\";\nimport { attachConfigurationReset } from \"./ConfigurationReset.js\";\n\nlet currThemeRoot: string | undefined;\n\nattachConfigurationReset(() => {\n\tcurrThemeRoot = undefined;\n});\n\n/**\n * Returns the current theme root.\n *\n * @public\n * @since 1.14.0\n * @returns { string } the current theme root\n */\nconst getThemeRoot = (): string | undefined => {\n\tif (currThemeRoot === undefined) {\n\t\tcurrThemeRoot = getConfiguredThemeRoot();\n\t}\n\n\treturn currThemeRoot;\n};\n\n/**\n * Sets theme root for the current theme.\n * When set, the framework will validate the theme root and fetch the theme styles (CSS variables) from this location.\n *\n * **Note:** The feature is specific to custom themes, created with the `UI Theme Designer`.\n * The provided theme root is used only as a base to construct the actual location of the theme styles: `{themeRoot}/.../css_variables.css`.\n *\n * **Note:** Certain security restrictions will apply before fetching the theme assets.\n * Absolute URLs to a different origin than the current page will result in using the current page as an origin.\n *\n * **Important:** To use this feature you must explicitly allow specific origins by using <meta name=\"sap-allowed-theme-origins\" content=\"https://my-example-host.com/\"> tag inside the <head> of the page.\n * Failing to do so will result in a warning in the console and the theme root will not be set.\n *\n * @public\n * @since 1.14.0\n * @param { string } themeRoot the new theme root\n * @returns { Promise<void> }\n */\nconst setThemeRoot = (themeRoot: string): Promise<void> | undefined => {\n\tif (currThemeRoot === themeRoot) {\n\t\treturn;\n\t}\n\n\tcurrThemeRoot = themeRoot;\n\n\treturn attachCustomThemeStylesToHead(getTheme());\n};\n\nconst formatThemeLink = (theme: string, validatedThemeRoot: string) => {\n\treturn `${validatedThemeRoot}Base/baseLib/${theme}/css_variables.css`;\n};\n\nconst attachCustomThemeStylesToHead = async (theme: string): Promise<void> => {\n\tconst link = document.querySelector(`[sap-ui-webcomponents-theme=\"${theme}\"]`);\n\n\tif (link) {\n\t\tdocument.head.removeChild(link);\n\t}\n\n\tconst themeRoot = getThemeRoot();\n\n\tif (!themeRoot) {\n\t\treturn;\n\t}\n\n\tconst validatedThemeRoot = validateThemeRoot(themeRoot);\n\n\tif (!validatedThemeRoot) {\n\t\tconsole.warn(`The ${themeRoot} is not valid. Check the allowed origins as suggested in the \"setThemeRoot\" description.`); // eslint-disable-line\n\t\treturn;\n\t}\n\n\tawait createLinkInHead(formatThemeLink(theme, validatedThemeRoot), { \"sap-ui-webcomponents-theme\": theme });\n};\n\nexport {\n\tgetThemeRoot,\n\tsetThemeRoot,\n\tattachCustomThemeStylesToHead,\n};\n"],
|
|
5
|
+
"mappings": "aAAA,OAAOA,MAAsB,8BAC7B,OAAOC,MAAuB,0BAC9B,OAAS,gBAAgBC,MAA8B,6BACvD,OAAS,YAAAC,MAAgB,aACzB,OAAS,4BAAAC,MAAgC,0BAEzC,IAAIC,EAEJD,EAAyB,IAAM,CAC9BC,EAAgB,MACjB,CAAC,EASD,MAAMC,EAAe,KAChBD,IAAkB,SACrBA,EAAgBH,EAAuB,GAGjCG,GAqBFE,EAAgBC,GAAiD,CACtE,GAAIH,IAAkBG,EAItB,OAAAH,EAAgBG,EAETC,EAA8BN,EAAS,CAAC,CAChD,EAEMO,EAAkB,CAACC,EAAeC,IAChC,GAAGA,CAAkB,gBAAgBD,CAAK,qBAG5CF,EAAgC,MAAOE,GAAiC,CAC7E,MAAME,EAAO,SAAS,cAAc,gCAAgCF,CAAK,IAAI,EAEzEE,GACH,SAAS,KAAK,YAAYA,CAAI,EAG/B,MAAML,EAAYF,EAAa,EAE/B,GAAI,CAACE,EACJ,OAGD,MAAMI,EAAqBX,EAAkBO,CAAS,EAEtD,GAAI,CAACI,EAAoB,CACxB,QAAQ,KAAK,OAAOJ,CAAS,0FAA0F,EACvH,MACD,CAEA,MAAMR,EAAiBU,EAAgBC,EAAOC,CAAkB,EAAG,CAAE,6BAA8BD,CAAM,CAAC,CAC3G,EAEA,OACCL,KAAA,aACAC,KAAA,aACAE,KAAA",
|
|
6
|
+
"names": ["createLinkInHead", "validateThemeRoot", "getConfiguredThemeRoot", "getTheme", "attachConfigurationReset", "currThemeRoot", "getThemeRoot", "setThemeRoot", "themeRoot", "attachCustomThemeStylesToHead", "formatThemeLink", "theme", "validatedThemeRoot", "link"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e={version:"2.14.
|
|
1
|
+
"use strict";const e={version:"2.14.1",major:2,minor:14,patch:1,suffix:"",isNext:!1,buildTime:1778504096};export default e;
|
|
2
2
|
//# sourceMappingURL=VersionInfo.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/generated/VersionInfo.ts"],
|
|
4
|
-
"sourcesContent": ["const VersionInfo = {\n\tversion: \"2.14.
|
|
4
|
+
"sourcesContent": ["const VersionInfo = {\n\tversion: \"2.14.1\",\n\tmajor: 2,\n\tminor: 14,\n\tpatch: 1,\n\tsuffix: \"\",\n\tisNext: false,\n\tbuildTime: 1778504096,\n};\nexport default VersionInfo;"],
|
|
5
5
|
"mappings": "aAAA,MAAMA,EAAc,CACnB,QAAS,SACT,MAAO,EACP,MAAO,GACP,MAAO,EACP,OAAQ,GACR,OAAQ,GACR,UAAW,UACZ,EACA,eAAeA",
|
|
6
6
|
"names": ["VersionInfo"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";import{getLocationHref as
|
|
1
|
+
"use strict";import{getLocationHref as s}from"./Location.js";const a=t=>{const e=document.querySelector(`META[name="${t}"]`);return e&&e.getAttribute("content")},g=(t,e=!1)=>{const n=a("sap-allowed-theme-origins")??a("sap-allowedThemeOrigins");return n?e?!0:n.split(",").some(r=>r==="*"||t===r.trim()):!1},l=t=>{let e,n=!1;try{if(t.startsWith(".")||t.startsWith("/")&&!t.startsWith("//"))e=new URL(t,s()).toString(),n=!0;else{const r=t.startsWith("//")?new URL(t,s()):new URL(t),i=r.origin,o=new URL(s()).origin;if(n=i===o,i&&g(i,n))e=r.toString();else return}return e.endsWith("/")||(e=`${e}/`),`${e}UI5/`}catch{return}};export default l;
|
|
2
2
|
//# sourceMappingURL=validateThemeRoot.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/validateThemeRoot.ts"],
|
|
4
|
-
"sourcesContent": ["import { getLocationHref } from \"./Location.js\";\n\nconst getMetaTagValue = (metaTagName: string) => {\n\tconst metaTag = document.querySelector(`META[name=\"${metaTagName}\"]`),\n\t\tmetaTagContent = metaTag && metaTag.getAttribute(\"content\");\n\n\treturn metaTagContent;\n};\n\nconst validateThemeOrigin = (origin: string) => {\n\tconst allowedOrigins = getMetaTagValue(\"sap-allowed-theme-origins\") ?? getMetaTagValue(\"sap-allowedThemeOrigins\"); // Prioritize the new meta tag name\n\n\t// If no allowed origins are specified, block.\n\tif (!allowedOrigins) {\n\t\treturn false;\n\t}\n\n\treturn allowedOrigins.split(\",\").some(allowedOrigin => {\n\t\treturn allowedOrigin === \"*\" || origin === allowedOrigin.trim();\n\t});\n};\n\nconst
|
|
5
|
-
"mappings": "aAAA,OAAS,mBAAAA,MAAuB,gBAEhC,MAAMC,EAAmBC,GAAwB,CAChD,MAAMC,EAAU,SAAS,cAAc,cAAcD,CAAW,IAAI,EAGpE,OAFkBC,GAAWA,EAAQ,aAAa,SAAS,CAG5D,EAEMC,
|
|
6
|
-
"names": ["getLocationHref", "getMetaTagValue", "metaTagName", "metaTag", "validateThemeOrigin", "origin", "
|
|
4
|
+
"sourcesContent": ["import { getLocationHref } from \"./Location.js\";\n\nconst getMetaTagValue = (metaTagName: string) => {\n\tconst metaTag = document.querySelector(`META[name=\"${metaTagName}\"]`),\n\t\tmetaTagContent = metaTag && metaTag.getAttribute(\"content\");\n\n\treturn metaTagContent;\n};\n\nconst validateThemeOrigin = (origin: string, isSameOrigin: boolean = false) => {\n\tconst allowedOrigins = getMetaTagValue(\"sap-allowed-theme-origins\") ?? getMetaTagValue(\"sap-allowedThemeOrigins\"); // Prioritize the new meta tag name\n\n\t// If no allowed origins are specified, block.\n\tif (!allowedOrigins) {\n\t\treturn false;\n\t}\n\n\t// If it's same-origin (relative URL resolved to current page), allow it when there's any meta tag present\n\t// The presence of the meta tag indicates the user wants to use theme roots\n\tif (isSameOrigin) {\n\t\treturn true;\n\t}\n\n\treturn allowedOrigins.split(\",\").some(allowedOrigin => {\n\t\treturn allowedOrigin === \"*\" || origin === allowedOrigin.trim();\n\t});\n};\n\nconst validateThemeRoot = (themeRoot: string) => {\n\tlet resultUrl;\n\tlet isSameOrigin = false;\n\n\ttry {\n\t\tif (themeRoot.startsWith(\".\") || (themeRoot.startsWith(\"/\") && !themeRoot.startsWith(\"//\"))) {\n\t\t\t// Handle relative url\n\t\t\t// new URL(\"/newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\t// new URL(\"./newExmPath\", \"http://example.com/exmPath\") => http://example.com/exmPath/newExmPath\n\t\t\t// new URL(\"../newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\tresultUrl = new URL(themeRoot, getLocationHref()).toString();\n\t\t\tisSameOrigin = true;\n\t\t} else {\n\t\t\t// Protocol-relative URLs (//host/path) need a base to resolve the protocol\n\t\t\tconst themeRootURL = themeRoot.startsWith(\"//\") ? new URL(themeRoot, getLocationHref()) : new URL(themeRoot);\n\t\t\tconst origin = themeRootURL.origin;\n\t\t\tconst currentOrigin = new URL(getLocationHref()).origin;\n\n\t\t\t// Check if the absolute URL is same-origin\n\t\t\tisSameOrigin = origin === currentOrigin;\n\n\t\t\tif (origin && validateThemeOrigin(origin, isSameOrigin)) {\n\t\t\t\t// If origin is allowed, use it\n\t\t\t\tresultUrl = themeRootURL.toString();\n\t\t\t} else {\n\t\t\t\t// If origin is not allowed, return undefined to indicate validation failed\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tif (!resultUrl.endsWith(\"/\")) {\n\t\t\tresultUrl = `${resultUrl}/`;\n\t\t}\n\n\t\treturn `${resultUrl}UI5/`;\n\t} catch (e) {\n\t\t// Catch if URL is not correct\n\t\treturn undefined;\n\t}\n};\n\nexport default validateThemeRoot;\n"],
|
|
5
|
+
"mappings": "aAAA,OAAS,mBAAAA,MAAuB,gBAEhC,MAAMC,EAAmBC,GAAwB,CAChD,MAAMC,EAAU,SAAS,cAAc,cAAcD,CAAW,IAAI,EAGpE,OAFkBC,GAAWA,EAAQ,aAAa,SAAS,CAG5D,EAEMC,EAAsB,CAACC,EAAgBC,EAAwB,KAAU,CAC9E,MAAMC,EAAiBN,EAAgB,2BAA2B,GAAKA,EAAgB,yBAAyB,EAGhH,OAAKM,EAMDD,EACI,GAGDC,EAAe,MAAM,GAAG,EAAE,KAAKC,GAC9BA,IAAkB,KAAOH,IAAWG,EAAc,KAAK,CAC9D,EAXO,EAYT,EAEMC,EAAqBC,GAAsB,CAChD,IAAIC,EACAL,EAAe,GAEnB,GAAI,CACH,GAAII,EAAU,WAAW,GAAG,GAAMA,EAAU,WAAW,GAAG,GAAK,CAACA,EAAU,WAAW,IAAI,EAKxFC,EAAY,IAAI,IAAID,EAAWV,EAAgB,CAAC,EAAE,SAAS,EAC3DM,EAAe,OACT,CAEN,MAAMM,EAAeF,EAAU,WAAW,IAAI,EAAI,IAAI,IAAIA,EAAWV,EAAgB,CAAC,EAAI,IAAI,IAAIU,CAAS,EACrGL,EAASO,EAAa,OACtBC,EAAgB,IAAI,IAAIb,EAAgB,CAAC,EAAE,OAKjD,GAFAM,EAAeD,IAAWQ,EAEtBR,GAAUD,EAAoBC,EAAQC,CAAY,EAErDK,EAAYC,EAAa,SAAS,MAGlC,OAEF,CAEA,OAAKD,EAAU,SAAS,GAAG,IAC1BA,EAAY,GAAGA,CAAS,KAGlB,GAAGA,CAAS,MACpB,MAAY,CAEX,MACD,CACD,EAEA,eAAeF",
|
|
6
|
+
"names": ["getLocationHref", "getMetaTagValue", "metaTagName", "metaTag", "validateThemeOrigin", "origin", "isSameOrigin", "allowedOrigins", "allowedOrigin", "validateThemeRoot", "themeRoot", "resultUrl", "themeRootURL", "currentOrigin"]
|
|
7
7
|
}
|
|
@@ -3,41 +3,47 @@ const getMetaTagValue = (metaTagName) => {
|
|
|
3
3
|
const metaTag = document.querySelector(`META[name="${metaTagName}"]`), metaTagContent = metaTag && metaTag.getAttribute("content");
|
|
4
4
|
return metaTagContent;
|
|
5
5
|
};
|
|
6
|
-
const validateThemeOrigin = (origin) => {
|
|
6
|
+
const validateThemeOrigin = (origin, isSameOrigin = false) => {
|
|
7
7
|
const allowedOrigins = getMetaTagValue("sap-allowed-theme-origins") ?? getMetaTagValue("sap-allowedThemeOrigins"); // Prioritize the new meta tag name
|
|
8
8
|
// If no allowed origins are specified, block.
|
|
9
9
|
if (!allowedOrigins) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
|
+
// If it's same-origin (relative URL resolved to current page), allow it when there's any meta tag present
|
|
13
|
+
// The presence of the meta tag indicates the user wants to use theme roots
|
|
14
|
+
if (isSameOrigin) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
12
17
|
return allowedOrigins.split(",").some(allowedOrigin => {
|
|
13
18
|
return allowedOrigin === "*" || origin === allowedOrigin.trim();
|
|
14
19
|
});
|
|
15
20
|
};
|
|
16
|
-
const buildCorrectUrl = (oldUrl, newOrigin) => {
|
|
17
|
-
const oldUrlPath = new URL(oldUrl).pathname;
|
|
18
|
-
return new URL(oldUrlPath, newOrigin).toString();
|
|
19
|
-
};
|
|
20
21
|
const validateThemeRoot = (themeRoot) => {
|
|
21
22
|
let resultUrl;
|
|
23
|
+
let isSameOrigin = false;
|
|
22
24
|
try {
|
|
23
|
-
if (themeRoot.startsWith(".") || themeRoot.startsWith("/")) {
|
|
25
|
+
if (themeRoot.startsWith(".") || (themeRoot.startsWith("/") && !themeRoot.startsWith("//"))) {
|
|
24
26
|
// Handle relative url
|
|
25
27
|
// new URL("/newExmPath", "http://example.com/exmPath") => http://example.com/newExmPath
|
|
26
28
|
// new URL("./newExmPath", "http://example.com/exmPath") => http://example.com/exmPath/newExmPath
|
|
27
29
|
// new URL("../newExmPath", "http://example.com/exmPath") => http://example.com/newExmPath
|
|
28
30
|
resultUrl = new URL(themeRoot, getLocationHref()).toString();
|
|
31
|
+
isSameOrigin = true;
|
|
29
32
|
}
|
|
30
33
|
else {
|
|
31
|
-
|
|
34
|
+
// Protocol-relative URLs (//host/path) need a base to resolve the protocol
|
|
35
|
+
const themeRootURL = themeRoot.startsWith("//") ? new URL(themeRoot, getLocationHref()) : new URL(themeRoot);
|
|
32
36
|
const origin = themeRootURL.origin;
|
|
33
|
-
|
|
37
|
+
const currentOrigin = new URL(getLocationHref()).origin;
|
|
38
|
+
// Check if the absolute URL is same-origin
|
|
39
|
+
isSameOrigin = origin === currentOrigin;
|
|
40
|
+
if (origin && validateThemeOrigin(origin, isSameOrigin)) {
|
|
34
41
|
// If origin is allowed, use it
|
|
35
42
|
resultUrl = themeRootURL.toString();
|
|
36
43
|
}
|
|
37
44
|
else {
|
|
38
|
-
// If origin is not
|
|
39
|
-
|
|
40
|
-
resultUrl = buildCorrectUrl(themeRootURL.toString(), getLocationHref());
|
|
45
|
+
// If origin is not allowed, return undefined to indicate validation failed
|
|
46
|
+
return undefined;
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
if (!resultUrl.endsWith("/")) {
|
|
@@ -47,6 +53,7 @@ const validateThemeRoot = (themeRoot) => {
|
|
|
47
53
|
}
|
|
48
54
|
catch (e) {
|
|
49
55
|
// Catch if URL is not correct
|
|
56
|
+
return undefined;
|
|
50
57
|
}
|
|
51
58
|
};
|
|
52
59
|
export default validateThemeRoot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateThemeRoot.js","sourceRoot":"","sources":["../src/validateThemeRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,eAAe,GAAG,CAAC,WAAmB,EAAE,EAAE;IAC/C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,cAAc,WAAW,IAAI,CAAC,E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C;AACF,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { getLocationHref } from \"./Location.js\";\n\nconst getMetaTagValue = (metaTagName: string) => {\n\tconst metaTag = document.querySelector(`META[name=\"${metaTagName}\"]`),\n\t\tmetaTagContent = metaTag && metaTag.getAttribute(\"content\");\n\n\treturn metaTagContent;\n};\n\nconst validateThemeOrigin = (origin: string, isSameOrigin: boolean = false) => {\n\tconst allowedOrigins = getMetaTagValue(\"sap-allowed-theme-origins\") ?? getMetaTagValue(\"sap-allowedThemeOrigins\"); // Prioritize the new meta tag name\n\n\t// If no allowed origins are specified, block.\n\tif (!allowedOrigins) {\n\t\treturn false;\n\t}\n\n\t// If it's same-origin (relative URL resolved to current page), allow it when there's any meta tag present\n\t// The presence of the meta tag indicates the user wants to use theme roots\n\tif (isSameOrigin) {\n\t\treturn true;\n\t}\n\n\treturn allowedOrigins.split(\",\").some(allowedOrigin => {\n\t\treturn allowedOrigin === \"*\" || origin === allowedOrigin.trim();\n\t});\n};\n\nconst validateThemeRoot = (themeRoot: string) => {\n\tlet resultUrl;\n\tlet isSameOrigin = false;\n\n\ttry {\n\t\tif (themeRoot.startsWith(\".\") || (themeRoot.startsWith(\"/\") && !themeRoot.startsWith(\"//\"))) {\n\t\t\t// Handle relative url\n\t\t\t// new URL(\"/newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\t// new URL(\"./newExmPath\", \"http://example.com/exmPath\") => http://example.com/exmPath/newExmPath\n\t\t\t// new URL(\"../newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\tresultUrl = new URL(themeRoot, getLocationHref()).toString();\n\t\t\tisSameOrigin = true;\n\t\t} else {\n\t\t\t// Protocol-relative URLs (//host/path) need a base to resolve the protocol\n\t\t\tconst themeRootURL = themeRoot.startsWith(\"//\") ? new URL(themeRoot, getLocationHref()) : new URL(themeRoot);\n\t\t\tconst origin = themeRootURL.origin;\n\t\t\tconst currentOrigin = new URL(getLocationHref()).origin;\n\n\t\t\t// Check if the absolute URL is same-origin\n\t\t\tisSameOrigin = origin === currentOrigin;\n\n\t\t\tif (origin && validateThemeOrigin(origin, isSameOrigin)) {\n\t\t\t\t// If origin is allowed, use it\n\t\t\t\tresultUrl = themeRootURL.toString();\n\t\t\t} else {\n\t\t\t\t// If origin is not allowed, return undefined to indicate validation failed\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tif (!resultUrl.endsWith(\"/\")) {\n\t\t\tresultUrl = `${resultUrl}/`;\n\t\t}\n\n\t\treturn `${resultUrl}UI5/`;\n\t} catch (e) {\n\t\t// Catch if URL is not correct\n\t\treturn undefined;\n\t}\n};\n\nexport default validateThemeRoot;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/webcomponents-base",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.1",
|
|
4
4
|
"description": "UI5 Web Components: webcomponents.base",
|
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/
|
|
16
|
+
"url": "https://github.com/UI5/webcomponents.git",
|
|
17
17
|
"directory": "packages/base"
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"@openui5/sap.ui.core": "1.120.17",
|
|
64
64
|
"@sap-theming/theming-base-content": "11.29.3",
|
|
65
65
|
"@ui5/cypress-internal": "0.0.0",
|
|
66
|
-
"@ui5/webcomponents-tools": "2.14.
|
|
67
|
-
"chromedriver": "^
|
|
66
|
+
"@ui5/webcomponents-tools": "2.14.1",
|
|
67
|
+
"chromedriver": "^147.0.0",
|
|
68
68
|
"clean-css": "^5.2.2",
|
|
69
69
|
"copy-and-watch": "^0.1.5",
|
|
70
70
|
"cross-env": "^7.0.3",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"resolve": "^1.20.0",
|
|
75
75
|
"touch": "^3.1.0"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "bfb0635420ceaf9e098caa648b04810fc64adc49"
|
|
78
78
|
}
|