(url)
| 1133 | } |
| 1134 | |
| 1135 | function getRightUrl(url){ |
| 1136 | var newUrl = url; |
| 1137 | if(/^magnet/.test(url)){ |
| 1138 | newUrl=newUrl.split("&")[0].substring(20); |
| 1139 | if(newUrl.length==32){ |
| 1140 | newUrl="magnet:?xt=urn:btih:" + base32To16(newUrl); |
| 1141 | }else{ |
| 1142 | newUrl=url; |
| 1143 | } |
| 1144 | }else if(/^\/\//.test(url)){ |
| 1145 | newUrl=location.protocol+url; |
| 1146 | } |
| 1147 | return newUrl; |
| 1148 | } |
| 1149 | |
| 1150 | function base32To16(str){ |
| 1151 | if(str.length % 8 !== 0 || /[0189]/.test(str)){ |