MCPcopy Index your code
hub / github.com/hoothin/UserScripts / parseTrustedTypes

Function parseTrustedTypes

Picviewer CE+/dist.user.js:12657–12676  ·  view source on GitHub ↗
(cspString)

Source from the content-addressed store, hash-verified

12655 var prefs;
12656
12657 function parseTrustedTypes(cspString) {
12658 const policies = new Set();
12659 let allowDuplicates = false;
12660 let ttDirectiveFound = false;
12661 const ttRegex = /trusted-types\s+([^;]+)/gi;
12662 let match;
12663
12664 while ((match = ttRegex.exec(cspString)) !== null) {
12665 ttDirectiveFound = true;
12666 match[1].trim().split(/\s+/)
12667 .forEach(name => {
12668 if (name === "'allow-duplicates'") {
12669 allowDuplicates = true;
12670 } else if (name !== "'none'") {
12671 policies.add(name.replace(/'/g, ''));
12672 }
12673 });
12674 }
12675 return { names: policies, allowDuplicates: allowDuplicates, ttDirectiveFound: ttDirectiveFound };
12676 }
12677
12678 async function getCspTrustedTypesInfo() {
12679 const combinedPolicies = new Set();

Callers 1

getCspTrustedTypesInfoFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected