MCPcopy
hub / github.com/pinokiocomputer/pinokio / matchPinokioInjectTargetToFrame

Function matchPinokioInjectTargetToFrame

full.js:2066–2084  ·  view source on GitHub ↗
(targets, frame, hints = {})

Source from the content-addressed store, hash-verified

2064}
2065
2066const matchPinokioInjectTargetToFrame = (targets, frame, hints = {}) => {
2067 if (!Array.isArray(targets) || !targets.length) {
2068 return null
2069 }
2070 const frameName = (frame && typeof frame.name === 'string' ? frame.name.trim() : '')
2071 || (typeof hints.frameName === 'string' ? hints.frameName.trim() : '')
2072 const frameUrl = normalizeInspectorUrl((frame && frame.url) || '')
2073 || normalizeInspectorUrl(typeof hints.frameUrl === 'string' ? hints.frameUrl.trim() : '')
2074
2075 let matched = null
2076 if (frameName) {
2077 matched = targets.find((entry) => entry.name && entry.name === frameName && (!entry.src || urlsRoughlyMatch(entry.src, frameUrl)))
2078 || targets.find((entry) => entry.name && entry.name === frameName)
2079 }
2080 if (!matched && frameUrl) {
2081 matched = targets.find((entry) => entry.src && urlsRoughlyMatch(entry.src, frameUrl)) || null
2082 }
2083 return matched
2084}
2085
2086const resolvePinokioInjectTargetMatch = ({ registry, frame, currentUrl, targetHints, descendantDepth = 0 }) => {
2087 if (!registry || !Array.isArray(registry.targets) || registry.targets.length === 0) {

Callers 1

Calls 2

normalizeInspectorUrlFunction · 0.85
urlsRoughlyMatchFunction · 0.85

Tested by

no test coverage detected