Skip to content

Commit

Permalink
Merge pull request #53 from oleg-om/feature/torrents-with-non-latin-c…
Browse files Browse the repository at this point in the history
…haracters

Incorrect work with non latin letters in torrent file or folder name
  • Loading branch information
tdjsnelling authored Aug 22, 2023
2 parents 515a2a0 + a072d94 commit 4b64aa6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"bittorrent-tracker": "9.19.0",
"body-parser": "^1.19.0",
"chalk": "^4.1.1",
"content-disposition": "^0.5.4",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
Expand Down
10 changes: 7 additions & 3 deletions api/src/controllers/torrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import crypto from "crypto";
import mongoose from "mongoose";
import { createNGrams, nGrams } from "mongoose-fuzzy-searching/helpers";
import slugify from "slugify";
import contentDisposition from "content-disposition";
import Torrent from "../schema/torrent";
import User from "../schema/user";
import Comment from "../schema/comment";
Expand Down Expand Up @@ -254,13 +255,16 @@ export const downloadTorrent = async (req, res, next) => {
delete parsed["announce-list"];
parsed.info.private = 1;

const fileName = `${parsed.info.name.toString()} - ${
process.env.SQ_SITE_NAME
}.torrent`;

res.setHeader("Content-Type", "application/x-bittorrent");
res.setHeader(
"Content-Disposition",
`attachment;filename=${parsed.info.name.toString()} - ${
process.env.SQ_SITE_NAME
}.torrent`
`attachment;filename=${contentDisposition(fileName)}`
);

res.write(bencode.encode(parsed));
res.end();
} catch (e) {
Expand Down

0 comments on commit 4b64aa6

Please sign in to comment.