MCPcopy
hub / github.com/mailvelope/mailvelope / detectHost

Function detectHost

src/content-scripts/main.js:82–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80}
81
82function 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
110function on() {
111 if (clientApiActive) {

Callers 1

initFunction · 0.85

Calls 1

matchPattern2RegExFunction · 0.90

Tested by

no test coverage detected