Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added get_name and get_comment

  • Loading branch information...
commit 41eb2f272af14c50041b1b8e5a9616cfa080272a 1 parent 1c04179
@deoxxa authored
Showing with 32 additions and 0 deletions.
  1. +32 −0 lib/torrent-util.js
View
32 lib/torrent-util.js
@@ -119,6 +119,38 @@ exports.get_size = function(torrent, strict) {
}
};
+exports.get_name = function(torrent) {
+ if (typeof torrent !== "object" || typeof torrent.info !== "object" || typeof torrent.info.name === "undefined") {
+ return null;
+ }
+
+ var name = torrent.info.name;
+
+ if (Buffer.isBuffer(name)) { name = name.toString(); }
+
+ if (typeof name !== "string") {
+ return null;
+ }
+
+ return name;
+};
+
+exports.get_comment = function(torrent) {
+ if (typeof torrent !== "object" || typeof torrent.comment === "undefined") {
+ return null;
+ }
+
+ var comment = torrent.comment;
+
+ if (Buffer.isBuffer(comment)) { comment = comment.toString(); }
+
+ if (typeof comment !== "string") {
+ return null;
+ }
+
+ return comment;
+};
+
exports.get_files = function(torrent) {
if (typeof torrent != "object" || typeof torrent.info != "object") {
return null;
Please sign in to comment.
Something went wrong with that request. Please try again.