Skip to content

Commit 84c8556

Browse files
committed
Added check for text content in MemeNG class.
1 parent 45216ed commit 84c8556

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

app/js/memeng.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ MemeNG.prototype.createMeme = function (opts) {
136136

137137
// var url = 'https://memegen.link/api/templates/' + id + '/' + MemeNG.encodeMemeText(topText) + '/' + MemeNG.encodeMemeText(bottomText) + '';
138138
url = url
139-
.replace('<top>', MemeNG.encodeMemeText(topText))
140-
.replace('<bottom>', MemeNG.encodeMemeText(bottomText));
139+
.replace('<top>', MemeNG.encodeMemeText(topText) || 'top')
140+
.replace('<bottom>', MemeNG.encodeMemeText(bottomText) || 'bottom');
141141

142142
var result = {
143143
url: url,
@@ -175,6 +175,7 @@ MemeNG.prototype.authenticate = function (email, password) {
175175
* @returns {XML|string}
176176
*/
177177
MemeNG.encodeMemeText = function (text) {
178+
if(!text)return null;
178179
return text
179180
.toLowerCase()
180181
.replace(/-/g, '--')

app/routes/bot.js

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ router.post('/slack', (req, res) => {
7070
res.send('Ouch. An error. ' + err.message);
7171
});
7272
}
73+
else{
74+
res.send('Sorry you provided incomplete information.');
75+
}
7376
}
7477
else{
7578
res.send('Oops. Something appears to have gone wrong.');

0 commit comments

Comments
 (0)