Skip to content

Commit

Permalink
fix reading cookies after set #66
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jun 3, 2022
1 parent b2beea3 commit 90d8d1a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 54 deletions.
18 changes: 1 addition & 17 deletions parser.js

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

18 changes: 1 addition & 17 deletions src/grammar.peg
Expand Up @@ -743,23 +743,7 @@ variable = global / scoped
set = set_cookie / set_local

set_cookie = "cookie." name:name _ "=" _ expr:expression {
return {
"type": "AssignmentExpression",
"operator": "=",
"left": property(
make_identifier('document'),
make_identifier('cookie')
),
"right": {
"type": "BinaryExpression",
"operator": "+",
"left": {
"type": "Literal",
"value": name + "="
},
"right": call(make_identifier('String'), expr)
}
};
return gaiman_call("set_cookie", literal(name), expr);
}

assign_operator = $("=" !"=" / "*=" / "+=" / "-=" / "%=" / "/=")
Expand Down
4 changes: 4 additions & 0 deletions src/prefix.js
Expand Up @@ -106,6 +106,10 @@ const Gaiman = {
},
get_extra(url) {
return $.get(url, $.noop, "text");
},
set_cookie(name, value) {
document.cookie = `${name}=${value}`;
cookie[name] = value;
}
};

Expand Down
20 changes: 2 additions & 18 deletions umd.js
Expand Up @@ -8,7 +8,7 @@
* Copyright (C) 2021 Jakub T. Jankiewicz <https://jcubic.pl/me>
*
* Released under GNU GPL v3 or later
* Buid time: Fri, 03 Jun 2022 08:49:17 GMT
* Buid time: Fri, 03 Jun 2022 23:50:13 GMT
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
Expand Down Expand Up @@ -850,23 +850,7 @@
return make_identifier(variable);
};
var peg$f54 = function(name, expr) {
return {
"type": "AssignmentExpression",
"operator": "=",
"left": property(
make_identifier('document'),
make_identifier('cookie')
),
"right": {
"type": "BinaryExpression",
"operator": "+",
"left": {
"type": "Literal",
"value": name + "="
},
"right": call(make_identifier('String'), expr)
}
};
return gaiman_call("set_cookie", literal(name), expr);
};
var peg$f55 = function(left, operator, right) {
return {
Expand Down
4 changes: 2 additions & 2 deletions umd.min.js

Large diffs are not rendered by default.

0 comments on commit 90d8d1a

Please sign in to comment.