Skip Menu |
 

This queue is for tickets about the JavaScript-Beautifier CPAN distribution.

Report information
The Basics
Id: 129976
Status: new
Priority: 0/
Queue: JavaScript-Beautifier

People
Owner: Nobody in particular
Requestors: x.guimard [...] free.fr
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.25
Fixed in: (no value)



Subject: "=>" operator replaced by "= >" thus creating syntax errors
Download (untitled) / with headers
text/plain 426b
Hello, This simple code becomes unusable when parsed by JavaScript::Beautifier: # SOURCE (test.js) fetch('https://example.com/').then(resp = >resp.blob()).then(blob = >{ alert('your file has downloaded!'); }). catch(() => alert('oh no!')); # RESULT $ js_beautify - <test.js fetch('https://example.com/').then(resp = >resp.blob()).then(blob = >{ alert('your file has downloaded!'); }). catch(() = >alert('oh no!'));
Download (untitled) / with headers
text/plain 537b
Le Mer 03 Jui 2019 12:25:52, GUIMARD a écrit : Show quoted text
> Hello, > > This simple code becomes unusable when parsed by JavaScript::Beautifier: > > # SOURCE (test.js) > fetch('https://example.com/').then(resp = >resp.blob()).then(blob = >{ > alert('your file has downloaded!'); > }). > catch(() => alert('oh no!')); > > # RESULT > $ js_beautify - <test.js > fetch('https://example.com/').then(resp = >resp.blob()).then(blob = >{ > alert('your file has downloaded!'); > }). > catch(() = >alert('oh no!'));
Quick and dirty fix attached
Subject: javascript-beautifier.diff
diff --git a/lib/JavaScript/Beautifier.pm b/lib/JavaScript/Beautifier.pm index 06d5981..66ecf5e 100644 --- a/lib/JavaScript/Beautifier.pm +++ b/lib/JavaScript/Beautifier.pm @@ -18,7 +18,7 @@ my @whitespace = split('', "\n\r\t "); my @wordchar = split('', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$'); my @digits = split('', '0123456789'); # <!-- is a special case (ok, it's a minor hack actually) -my @punct = split(' ', '+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::'); +my @punct = split(' ', '+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= => >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::'); # words which should always start on new line. my @line_starter = split(',', 'continue,try,throw,return,var,if,switch,case,default,for,while,break,function');


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.