(js_content)
| 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 | })(); |
no test coverage detected