Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support add BT-magnet hash code URI directly #468

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions js/ctrls/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ angular
});
})
.filter(function(d) { return d.length })
.map(function(u){
/// transform bt-key into legal magnet link
/// support BASE32 encoding key string or HEX encoding key string
var str=_.toUpper(u[0])
var hashkey=_.head(_.split(str,"&"))//maybe url contains additional attribute such as dn/tr
const base32Regex=/^[2-7 | A-Z]{32}$/
const hexRegex=/^[0-9 | A-Z]{40}$/
if(base32Regex.test(hashkey)||hexRegex.test(hashkey)){
u[0]= "magnet:?xt=urn:btih:"+u[0]
// if hashkey is legal bt-hashkey string then add protocol's head
// only support 32-bit length HEX encoding string or 40-bit length BASE32 length encoding string
}
return u
})
.value();
}
};
Expand Down