File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,20 @@ export default angular
106
106
. filter ( function ( d ) {
107
107
return d . length ;
108
108
} )
109
+ . map ( function ( u ) {
110
+ /// transform bt-key into legal magnet link
111
+ /// support BASE32 encoding key string or HEX encoding key string
112
+ var str = _ . toUpper ( u [ 0 ] ) ;
113
+ var hashkey = _ . head ( _ . split ( str , "&" ) ) ; //maybe url contains additional attribute such as dn/tr
114
+ const base32Regex = / ^ [ 2 - 7 | A - Z ] { 32 } $ / ;
115
+ const hexRegex = / ^ [ 0 - 9 | A - Z ] { 40 } $ / ;
116
+ if ( base32Regex . test ( hashkey ) || hexRegex . test ( hashkey ) ) {
117
+ u [ 0 ] = "magnet:?xt=urn:btih:" + u [ 0 ] ;
118
+ // if hashkey is legal bt-hashkey string then add protocol's head
119
+ // only support 32-bit length HEX encoding string or 40-bit length BASE32 length encoding string
120
+ }
121
+ return u ;
122
+ } )
109
123
. value ( ) ;
110
124
}
111
125
} ;
You can’t perform that action at this time.
0 commit comments