MCPcopy Create free account
hub / github.com/tailscale/tailcat / pickDERPMapURL

Function pickDERPMapURL

web/app.js:21–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19// prefers a same-origin derpmap.json if the host serves one and
20// otherwise falls back to the canonical map.
21async function pickDERPMapURL() {
22 if (params.get("derpmap")) {
23 return new URL(params.get("derpmap"), location.href).toString();
24 }
25 if (location.hostname.endsWith(".github.io")) {
26 return canonicalDERPMapURL;
27 }
28 const sameOrigin = new URL("derpmap.json", location.href).toString();
29 try {
30 const resp = await fetch(sameOrigin, { method: "HEAD" });
31 if (resp.ok) {
32 return sameOrigin;
33 }
34 } catch (e) {}
35 return canonicalDERPMapURL;
36}
37const derpMapURL = await pickDERPMapURL();
38
39// tcTest is the state surface polled by the headless-browser

Callers 1

app.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected