Skip to content

Commit

Permalink
Fix path length bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroCB committed Mar 24, 2021
1 parent 161cc65 commit 5f64ace
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,7 @@ exports.getAllScores = (groupInfo, callback = () => { }) => {
// Accepts url, threadId, and optional error message parameter to be displayed if changing the group image fails
exports.setGroupImageFromUrl = (url, threadId, errMsg = "Photo couldn't download properly", api = gapi) => {
// Download file and pass to chat API (see config for details)
// 10 is length of rest of path string (media/.png)
const path = `../media/${encodeURIComponent(url.substring(0, config.MAXPATH - 10))}.png`;
const path = `../media/${encodeURIComponent(url).slice(0, config.MAXPATH)}.png`;
const fullpath = `${__dirname}/${path}`;
request(url).pipe(fs.createWriteStream(fullpath)).on('close', err => {
if (!err) {
Expand Down

0 comments on commit 5f64ace

Please sign in to comment.