From 9105c3563e0333ecc6d05632351c41139946da00 Mon Sep 17 00:00:00 2001 From: Ashley Graves Date: Wed, 16 Oct 2024 01:42:04 +0200 Subject: [PATCH] guh --- src/commands/utility/file.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/commands/utility/file.js b/src/commands/utility/file.js index 66092d0..5d5ef25 100644 --- a/src/commands/utility/file.js +++ b/src/commands/utility/file.js @@ -26,8 +26,16 @@ function notEmpty(str) { return str && str.trim() !== '' } +/** + * @param {string} str + * @param {number} len + */ function shorten(str) { - return str.length <= 20 ? str : `[${str.slice(0, 17)}...](${str})`; + const len = 50; + + var urlStart = str.indexOf("://") + 3; + if (urlStart == 2) urlStart = 0; + return str.length <= len ? str : `[${str.slice(urlStart, urlStart + (len - 3))}...](${str.startsWith("magnet:") ? (`${process.env.BASE_URL}/magnet/${str}`) : str})`; } const emojis = JSON.parse(readFileSync("config/emojis.json")); @@ -89,4 +97,4 @@ module.exports = { }); pagination.render(); } -} +} \ No newline at end of file