Skip to content

Commit

Permalink
Added two new methods:
Browse files Browse the repository at this point in the history
compressToEncodedURIComponent: compress into a string that is already URI encoded

decompressFromEncodedURIComponent: the associated decompress method
  • Loading branch information
pieroxy committed Nov 30, 2014
1 parent 1bb84be commit 3dd0b67
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
13 changes: 12 additions & 1 deletion libs/lz-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// For more information, the home page:
// http://pieroxy.net/blog/pages/lz-string/testing.html
//
// LZ-based compression algorithm, version 1.3.4
// LZ-based compression algorithm, version 1.3.5
var LZString = {


Expand Down Expand Up @@ -310,6 +310,17 @@ var LZString = {

},

//compress into a string that is already URI encoded
compressToEncodedURIComponent: function (uncompressed) {
return LZString.compressToBase64(uncompressed).replace("=","$").replace("/","-");
},

//decompress from an output of compressToEncodedURIComponent
decompressFromEncodedURIComponent:function (compressed) {
if (compressed) compressed = compressed.replace("$","=").replace("-","/");
return LZString.decompressFromBase64(compressed);
},


compress: function (uncompressed) {
if (uncompressed == null) return "";
Expand Down
Loading

0 comments on commit 3dd0b67

Please sign in to comment.