Skip to content
Browse files

^ eats first character

  • Loading branch information...
1 parent cba2be5 commit 2298c30f3f1fc35596b18044b5bff2fa4fb513fd @vrana committed Mar 9, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 jsShrink.js
View
2 jsShrink.js
@@ -8,7 +8,7 @@
*/
function jsShrink(input) {
var last = '';
- return (input + '\n').replace(/(?:(^|[-+\([{}=,:;!%^&*|?~]|\/(?![/*])|return|throw)(?:\s|\/\/[^\n]*\n|\/\*(?:[^*]|\*(?!\/))*\*\/)*(\/(?![/*])(?:\\[^\n]|[^[\n\/\\]|\[(?:\\[^\n]|[^\]])+)+\/)|(^|'(?:\\[\s\S]|[^\n'\\])*'|"(?:\\[\s\S]|[^\n"\\])*"|([0-9A-Za-z_$]+)|([-+]+)|.))(?:\s|\/\/[^\n]*\n|\/\*(?:[^*]|\*(?!\/))*\*\/)*/g, function (str, context, regexp, result, word, operator) {
+ return ('\n' + input + '\n').replace(/(?:(^|[-+\([{}=,:;!%^&*|?~]|\/(?![/*])|return|throw)(?:\s|\/\/[^\n]*\n|\/\*(?:[^*]|\*(?!\/))*\*\/)*(\/(?![/*])(?:\\[^\n]|[^[\n\/\\]|\[(?:\\[^\n]|[^\]])+)+\/)|(^|'(?:\\[\s\S]|[^\n'\\])*'|"(?:\\[\s\S]|[^\n"\\])*"|([0-9A-Za-z_$]+)|([-+]+)|.))(?:\s|\/\/[^\n]*\n|\/\*(?:[^*]|\*(?!\/))*\*\/)*/g, function (str, context, regexp, result, word, operator) {
if (word) {
result = (last == 'word' ? '\n' : (last == 'return' ? ' ' : '')) + result;
last = (word == 'return' || word == 'throw' || word == 'break' ? 'return' : 'word');

0 comments on commit 2298c30

Please sign in to comment.
Something went wrong with that request. Please try again.