MCPcopy Create free account
hub / github.com/FastForwardTeam/FastForward / isGoodLink

Function isGoodLink

src/js/background.js:23–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21},
22encodedRedirect=(url,referer,safe_in)=>getRedirect(decodeURIComponent(url),referer,safe_in),
23isGoodLink=link=>{
24 if(typeof link !== "string"||(link.split("#")[0]==location.href.split("#")[0]&&!isGoodLink_allowSelf))
25 {
26 return false
27 }
28 try
29 {
30 let u = new URL(decodeURI(link).trim().toLocaleLowerCase())
31 //check if host is a private/internal ip
32 if (u.hostname === 'localhost' || u.hostname === '[::1]' || /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/.test(u.hostname)) {
33 return false
34 }
35 var parts = u.hostname.split('.');
36 if (parts[0] === '10' || (parts[0] === '172' && (parseInt(parts[1], 10) >= 16 && parseInt(parts[1], 10) <= 31)) || (parts[0] === '192' && parts[1] === '168')) {
37 return false
38 }
39 // Check if protocol is safe
40 let safeProtocols = ["http:", "https:", "mailto:", "irc:", "telnet:", "tel:", "svn:"]
41 if (!safeProtocols.includes(u.protocol)) {
42 return false
43 }
44 }
45 catch(e)
46 {
47 return false
48 }
49 return true
50},
51countIt=()=>{
52 brws.storage.local.set({bypass_counter:++bypassCounter})
53 sendToOptions({bypassCounter})

Callers 2

getRedirectFunction · 0.70
background.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected