Skip to content

Commit

Permalink
Fix empty field bugs causing htaccess to mess up
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnl authored Jan 18, 2022
1 parent 37b61cb commit 5c8da51
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ client.on('message', async (message) => {
if (memeName.length > maxMemeNameLength) {
memeName = memeName.slice(0, -(memeName.length - maxMemeNameLength))
}

// Sanitize the meme name and find an available file path for it
const availableFilename = await utils.findAvailableFilename(uploadDirectory,
utils.alphanum(`${memeName}.${extension}`))
(utils.alphanum(memeName) || "nimetön") + "." + utils.alphanum(extension))
const filePath = path.join(uploadDirectory, availableFilename)

// Download the meme file from Discord's CDN and write it to disk
Expand All @@ -77,7 +77,7 @@ client.on('message', async (message) => {

// The name of the uploader of the file is shown in Apache directory listing
fsp.appendFile(htaccessPath,
`AddDescription "${utils.alphanum(message.author.username)}" ${availableFilename}\n`)
`AddDescription "${utils.alphanum(message.author.username) || "matti"}" ${availableFilename}\n`)

console.log(`Successfully uploaded ${availableFilename} by ${message.author.tag}`)
} catch (e) {
Expand Down

0 comments on commit 5c8da51

Please sign in to comment.