From 1c33c0dc8f70c07af38bb6fb785c43284eb37c46 Mon Sep 17 00:00:00 2001 From: the-happy-hippo Date: Wed, 7 May 2014 22:00:20 +0300 Subject: [PATCH] Fix chaimpeck/spray#3 Add guard of zero or negative num in String.repeat(num) so it won't crash on long words. --- content/js/spray-reader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/js/spray-reader.js b/content/js/spray-reader.js index 29513a2..dad688c 100644 --- a/content/js/spray-reader.js +++ b/content/js/spray-reader.js @@ -153,5 +153,5 @@ function pivot(word){ // Let strings repeat themselves, // because JavaScript isn't as awesome as Python. String.prototype.repeat = function( num ){ - return new Array( num + 1 ).join( this ); + return (num<=0) ? "" : new Array( num + 1 ).join( this ); }