All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.prod.validateThemeRoot.js.map Maven / Gradle / Ivy

{
  "version": 3,
  "sources": ["../../src/validateThemeRoot.ts"],
  "sourcesContent": ["const 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-allowedThemeOrigins\");\n\n\treturn allowedOrigins && allowedOrigins.split(\",\").some(allowedOrigin => {\n\t\treturn allowedOrigin === \"*\" || origin === allowedOrigin.trim();\n\t});\n};\n\nconst buildCorrectUrl = (oldUrl: string, newOrigin: string) => {\n\tconst oldUrlPath = new URL(oldUrl).pathname;\n\n\treturn new URL(oldUrlPath, newOrigin).toString();\n};\n\nconst validateThemeRoot = (themeRoot: string) => {\n\tlet resultUrl;\n\n\ttry {\n\t\tif (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, window.location.href).toString();\n\t\t} else {\n\t\t\tconst themeRootURL = new URL(themeRoot);\n\t\t\tconst origin = themeRootURL.origin;\n\n\t\t\tif (origin && validateThemeOrigin(origin)) {\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 allow and the URL is not relative, we have to replace the origin\n\t\t\t\t// with current location\n\t\t\t\tresultUrl = buildCorrectUrl(themeRootURL.toString(), window.location.href);\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}\n};\n\nexport default validateThemeRoot;\n"],
  "mappings": "aAAA,MAAMA,EAAmBC,GAAwB,CAChD,MAAMC,EAAU,SAAS,cAAc,cAAcD,CAAW,IAAI,EAGpE,OAFkBC,GAAWA,EAAQ,aAAa,SAAS,CAG5D,EAEMC,EAAuBC,GAAmB,CAC/C,MAAMC,EAAiBL,EAAgB,yBAAyB,EAEhE,OAAOK,GAAkBA,EAAe,MAAM,GAAG,EAAE,KAAKC,GAChDA,IAAkB,KAAOF,IAAWE,EAAc,KAAK,CAC9D,CACF,EAEMC,EAAkB,CAACC,EAAgBC,IAAsB,CAC9D,MAAMC,EAAa,IAAI,IAAIF,CAAM,EAAE,SAEnC,OAAO,IAAI,IAAIE,EAAYD,CAAS,EAAE,SAAS,CAChD,EAEME,EAAqBC,GAAsB,CAChD,IAAIC,EAEJ,GAAI,CACH,GAAID,EAAU,WAAW,GAAG,GAAKA,EAAU,WAAW,GAAG,EAKxDC,EAAY,IAAI,IAAID,EAAW,OAAO,SAAS,IAAI,EAAE,SAAS,MACxD,CACN,MAAME,EAAe,IAAI,IAAIF,CAAS,EAChCR,EAASU,EAAa,OAExBV,GAAUD,EAAoBC,CAAM,EAEvCS,EAAYC,EAAa,SAAS,EAIlCD,EAAYN,EAAgBO,EAAa,SAAS,EAAG,OAAO,SAAS,IAAI,CAE3E,CAEA,OAAKD,EAAU,SAAS,GAAG,IAC1BA,EAAY,GAAGA,CAAS,KAGlB,GAAGA,CAAS,MACpB,MAAY,CAEZ,CACD,EAEA,eAAeF",
  "names": ["getMetaTagValue", "metaTagName", "metaTag", "validateThemeOrigin", "origin", "allowedOrigins", "allowedOrigin", "buildCorrectUrl", "oldUrl", "newOrigin", "oldUrlPath", "validateThemeRoot", "themeRoot", "resultUrl", "themeRootURL"]
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy