Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release/0.4.1'

  • Loading branch information...
commit fb92f6c848345c258aeee45502bfd03839755e51 2 parents 1c04179 + 281e48d
@deoxxa authored
Showing with 34 additions and 2 deletions.
  1. +33 −1 lib/torrent-util.js
  2. +1 −1  package.json
View
34 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;
@@ -127,7 +159,7 @@ exports.get_files = function(torrent) {
if (typeof torrent.info.files == "object" && torrent.info.files instanceof Array) {
return torrent.info.files.map(function(file) {
if (typeof file != "object") { return; }
- if (typeof file.path == "object" && file.path instanceof Array) { file.path = file.path.shift(); }
+ if (typeof file.path == "object" && file.path instanceof Array) { file.path = file.path.join("/"); }
if (typeof file.path == "object" && Buffer.isBuffer(file.path)) { file.path = file.path.toString(); }
if (typeof file.path != "string" || typeof file.length != "number") { return; }
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "torrent-util",
"description": "Various utility functions for making sense of .torrent files",
- "version": "0.3.1",
+ "version": "0.4.1",
"author": {
"name": "Conrad Pankoff",
"email": "deoxxa@fknsrs.biz",
Please sign in to comment.
Something went wrong with that request. Please try again.