Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaves few whitespaces at the end #8

Closed
syst3mw0rm opened this issue Apr 24, 2014 · 5 comments
Closed

Leaves few whitespaces at the end #8

syst3mw0rm opened this issue Apr 24, 2014 · 5 comments

Comments

@syst3mw0rm
Copy link

For an example, I've tried to minify JSON document here - https://gist.github.com/syst3mw0rm/11240696 and the output I got is - https://gist.github.com/syst3mw0rm/11240705 which contains few whitespaces at the end which we should get rid off in minified version.

@fkei
Copy link
Owner

fkei commented Apr 24, 2014

I tried to minify this json.

Use below code.

// foo.js
var fs = require("fs");
var jsonminify = require("jsonminify");
var raw = fs.readFileSync('/tmp/11240696/gistfile1.txt', 'utf-8');

var out = jsonminify(raw);

console.log("---------");
console.log(out)
console.log("---------");

But output has no whitespece.

$ node foo.js
---------
{"glossary":{"title":"example glossary","GlossDiv":{"title":"S","GlossList":{"GlossEntry":{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":{"para":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML"]},"GlossSee":"markup"}}}}}
---------

I have no idea why your output has whitespace.

@tomByrer
Copy link

tomByrer commented May 1, 2014

I have no idea why your output has whitespace.

Perhaps they are tabs, hard-space, or other whitespace that the RegEx doesn't check?
No way to check without seeing the source files inside a .ZIP or 7z archive @syst3mw0rm

@syst3mw0rm
Copy link
Author

ok, I've uploaded relevant source code here - https://dl.dropboxusercontent.com/u/9555782/json-minify.zip

Code is bit involved than just json minification and it is quite possible that the bug is not in json minify itself but some other piece of code. Code is pretty straightforward to understand and see what's going on. I'm still unable to figure out from where does mysterious trailing whitespaces appear. Help is much appreciated.

@fkei
Copy link
Owner

fkei commented May 2, 2014

I can get reproduce the bug, but the cause is unknown.

It works correctly with text format (ex: #8 (comment)), so I think server is the cause of this bug.

I'll close this issue, but if you can reproduce the bug with text format(not binary format), give me the code and reopen this issue plase.

@fkei fkei closed this as completed May 2, 2014
@syst3mw0rm
Copy link
Author

Yeah, not a problem. Probably this ain't issue with json-minify anyway.

But, What do you by reproducing it in text format and giving you the code? I think I already did that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants