MCPcopy Create free account
hub / github.com/Threezh1/Deconstruct / extract_url

Function extract_url

DevTools_JSFinder/JSFinder.js:66–82  ·  view source on GitHub ↗
(js_content)

Source from the content-addressed store, hash-verified

64 return result
65 }
66 function extract_url(js_content){
67 let regex = /(?:"|')(((?:[a-zA-Z]{1,10}:\/\/|\/\/)[^"'\/]{1,}\.[a-zA-Z]{2,}[^"']{0,})|((?:\/|\.\.\/|\.\/)[^"'><,;| *()(%%$^\/\\\[\]][^"'><,;|()]{1,})|([a-zA-Z0-9_\-\/]{1,}\/[a-zA-Z0-9_\-\/]{1,}\.(?:[a-zA-Z]{1,4}|action)(?:[\?|\/][^"|']{0,}|))|([a-zA-Z0-9_\-]{1,}\.(?:php|asp|aspx|jsp|json|action|html|js|txt|xml)(?:\?[^"|']{0,}|)))(?:"|')/sg;
68 let m; result = [];
69 while ((m = regex.exec(js_content)) !== null) {
70 if (m.index === regex.lastIndex) { regex.lastIndex++;}
71 m.forEach((match, groupIndex) => {
72 if (match != undefined) {
73 match = match.replaceAll(/('|")/g, "");
74 if (match.startsWith("http") == true){
75 let suburl = new URL(match);
76 if (suburl.host.endsWith(getMainHost()) == true){ result.push(match); }
77 }else{
78 let url = new URL(match, location.origin);
79 if (url.host.endsWith(getMainHost()) == true){ result.push(url.href); }
80 }}});}
81 return Array.from(new Set(result));
82 }
83})();

Callers 1

JSFinder.jsFile · 0.85

Calls 1

getMainHostFunction · 0.85

Tested by

no test coverage detected