Skip to content

Commit

Permalink
build: update pako library.
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Dec 22, 2021
1 parent 53f703d commit d9c5095
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
17 changes: 12 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^3.0.5",
"nib": "^1.1.2",
"pako": "^1.0.11",
"pako": "^2.0.4",
"phantomjs-prebuilt": "^2.1.5",
"pug": "^3.0.2",
"pug-lint": "^2.6.0",
Expand Down
6 changes: 4 additions & 2 deletions tutorials/common/tutorials.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ function fill_codeblocks(query) {
/* Strip out white space and pluses, then convert ., -, and _ to /, +,
* =. By removing whitespace, the url is more robust against email
* handling. The others keep things short. */
var src = atob(query[key].replace(/(\s|\+)/g, '').replace(/\./g, '/').replace(/-/g, '+').replace(/_/g, '='));
let src = query[key].replace(/(\s|\+)/g, '').replace(/\./g, '/').replace(/-/g, '+').replace(/_/g, '=');
console.log(query[key], src, pako); // DWM::
src = pako.inflate(src, {to: 'string', raw: true});
if ($('.CodeMirror', block).length) {
$('.CodeMirror', block)[0].CodeMirror.setValue(src);
Expand Down Expand Up @@ -287,7 +288,8 @@ function start_keeper(alwaysKeep) {
var src = $('.CodeMirror', block).length ? $('.CodeMirror', block)[0].CodeMirror.getValue() : $('textarea', block).val();
src = src.trim().replace(/ [ ]*\n/g, '\n');
if (src !== defaultSrc) {
var comp = btoa(pako.deflate(src, {to: 'string', level: 9, raw: true}));
let comp = pako.deflate(src, {to: 'string', level: 9, raw: true});
comp = btoa(String.fromCharCode.apply(null, comp));
/* instead of using regular base64, convert /, +, and = to ., -, and _
* so that they don't need to be escaped on the url. This reduces the
* average length of the url by 6 percent. */
Expand Down

0 comments on commit d9c5095

Please sign in to comment.