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

Function findDescendantByUrl

full.js:934–959  ·  view source on GitHub ↗
(frame, targetUrl)

Source from the content-addressed store, hash-verified

932}
933
934const findDescendantByUrl = (frame, targetUrl) => {
935 if (!frame || !targetUrl) {
936 return null
937 }
938 const normalizedTarget = normalizeInspectorUrl(targetUrl)
939 if (!normalizedTarget) {
940 return null
941 }
942 const stack = [frame]
943 while (stack.length) {
944 const current = stack.pop()
945 try {
946 const currentUrl = normalizeInspectorUrl(current.url || '')
947 if (currentUrl && urlsRoughlyMatch(normalizedTarget, currentUrl)) {
948 return current
949 }
950 } catch (_) {}
951 const children = Array.isArray(current.frames) ? current.frames : []
952 for (const child of children) {
953 if (child) {
954 stack.push(child)
955 }
956 }
957 }
958 return null
959}
960
961const selectTargetFrame = (webContents, payload = {}) => {
962 if (!webContents || !webContents.mainFrame) {

Callers 1

selectTargetFrameFunction · 0.85

Calls 2

normalizeInspectorUrlFunction · 0.85
urlsRoughlyMatchFunction · 0.85

Tested by

no test coverage detected