Skip to content

Commit 024e378

Browse files
authored
Merge pull request #682 from Feder1co5oave/fix_typeerror
Throw error on non-string input
2 parents 68aab24 + 1ec0bf3 commit 024e378

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/marked.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,14 @@ function merge(obj) {
12141214
*/
12151215

12161216
function marked(src, opt, callback) {
1217+
// throw error in case of non string input
1218+
if (typeof src == 'undefined' || src === null)
1219+
throw new Error('marked(): input parameter is undefined or null');
1220+
if (typeof src != 'string')
1221+
throw new Error('marked(): input parameter is of type ' +
1222+
Object.prototype.toString.call(src) + ', string expected');
1223+
1224+
12171225
if (callback || typeof opt === 'function') {
12181226
if (!callback) {
12191227
callback = opt;

0 commit comments

Comments
 (0)