Skip to content

Commit 0cb5368

Browse files
committed
do not slugify tags so any locale can be used
1 parent 0fef96b commit 0cb5368

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

api/src/controllers/torrent.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ import Comment from "../schema/comment";
99
import Group from "../schema/group";
1010
import { createGroup, addToGroup, removeFromGroup } from "./group";
1111

12+
const urlReservedCharRegex = /[&$+,/:;=?@#<>\[\]{}|\\\^%]/g;
13+
14+
const formatTag = (tag) =>
15+
tag
16+
.trim()
17+
.toLowerCase()
18+
.replaceAll(urlReservedCharRegex, "")
19+
.replaceAll(" ", "-");
20+
1221
export const embellishTorrentsWithTrackerScrape = async (tracker, torrents) => {
1322
if (!torrents.length) return [];
1423

@@ -127,9 +136,7 @@ export const uploadTorrent = async (req, res, next) => {
127136
upvotes: [],
128137
downvotes: [],
129138
freeleech: false,
130-
tags: (req.body.tags ?? "")
131-
.split(",")
132-
.map((t) => slugify(t.trim(), { lower: true })),
139+
tags: (req.body.tags ?? "").split(",").map((t) => formatTag(t)),
133140
group: groupId,
134141
mediaInfo: req.body.mediaInfo,
135142
});
@@ -200,9 +207,7 @@ export const editTorrent = async (req, res, next) => {
200207
type: req.body.type,
201208
source: req.body.source,
202209
description: req.body.description,
203-
tags: (req.body.tags ?? "")
204-
.split(",")
205-
.map((t) => slugify(t.trim(), { lower: true })),
210+
tags: (req.body.tags ?? "").split(",").map((t) => formatTag(t)),
206211
},
207212
mediaInfo: req.body.mediaInfo,
208213
}
@@ -684,7 +689,7 @@ export const searchTorrents = (tracker) => async (req, res, next) => {
684689
query: query ? decodeURIComponent(query) : undefined,
685690
category,
686691
source,
687-
tag,
692+
tag: tag ? decodeURIComponent(tag) : undefined,
688693
userId: req.userId,
689694
tracker,
690695
});

0 commit comments

Comments
 (0)