()
| 80 | } |
| 81 | |
| 82 | function detectHost() { |
| 83 | for (const site of watchList) { |
| 84 | if (!site.active || !site.frames) { |
| 85 | continue; |
| 86 | } |
| 87 | for (const frame of site.frames) { |
| 88 | if (!frame.scan) { |
| 89 | continue; |
| 90 | } |
| 91 | const hostRegex = matchPattern2RegEx(frame.frame); |
| 92 | let hostID = window.location.hostname; |
| 93 | const port = window.location.port; |
| 94 | if (port && frame.frame.includes(':')) { |
| 95 | hostID = `${hostID}:${port}`; |
| 96 | } |
| 97 | const validHost = hostRegex.test(hostID); |
| 98 | if (validHost) { |
| 99 | // host = match pattern without *. prefix |
| 100 | host = frame.frame.replace(/^\*\./, ''); |
| 101 | if (frame.api) { |
| 102 | clientApiActive = true; |
| 103 | return; |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | function on() { |
| 111 | if (clientApiActive) { |
no test coverage detected