-
Notifications
You must be signed in to change notification settings - Fork 569
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
Apparent incompatibility between lz-string, Google Apps Script and ISO dates #124
Comments
Can't reproduce it. Can you give some context? In which browser are you seeing this ? |
I think @ipekarik is trying to use LZString from within Google App Script? I can reproduce it. Here is a link to my example AppScript. Note that I have both 1.4.4 and 2.0RC versions:
In the not-yet-released 2.0 version this bug vanishes:
Technically speaking, Google Apps Script is not JavaScript so incompatibilities are possible. Having said that, its wikipedia page claims it "is based on JavaScript 1.6 with some portions of 1.7 and 1.8 and provides subset of ECMAScript 5 API", so it looks like it should work. This might be a bug in App Script. Anyway, assuming you are manually inlining the LZString library anyway, you might as well throw the 2.0RC version through a minifier and use that as a work-around. |
Thinking of the code differences between 1.4.4 and 2.0RC, the most obvious candidate would be that LZString 1.4.4 uses a dictionary. It might be that AppScript mistakes "-0" for a 0 numerical key. Also, when I ran this script again today 1.4.4 was fixed as well, so the behavior seems inconsistent :/ |
It seems that GAS somehow breaks compression/decompression of ISO dates: the hyphens from the dates are corrupted.
var decompressed = '2018-03-01';
var compressed = LZString.compress(decompressed);
decompressed = LZString.decompress(compressed);
Logger.log(decompressed); // 20180301
The same is true for compressToUTF16 and compressToBase64.
EDIT:
It seems that the problem is in the substring "-0". For example if the date is 2018-11-11, the decompressed string will contain the hyphens.
If a string contains the sequence "-0", one of two things (that I managed to identify so far) happen:
a) if the hyphen is preceded by a digit, the hyphen is lost, and the zero preserved:
10-01 -> 1001
02-02 -> 0202
b) if the hyphen is preceded by a character, the zero is lost, and the hyphen preserved:
TEST-01 -> TEST-1
TEST/-02/ -> TEST/-2/
TEST*-03* -> TEST*-3*
The text was updated successfully, but these errors were encountered: