Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Jan 19, 2025
1 parent 58c36bb commit 66a660e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class Cookie

value = encodeURIComponent(value).replace(
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
window.decodeURIComponent
decodeURIComponent
);

if (typeof expires === 'number') {
Expand Down Expand Up @@ -63,14 +63,15 @@ export default class Cookie
* @param {*} value
* @return {*}
*/
get(key, value = null)
get(key, value = '')
{
key = this._qualify(key);

const cookie = document.cookie.match(new RegExp('(^| )' + key + '=([^;]+)'));
const value = (cookie && cookie[2]) ? cookie[2] : value;

return value.replace(/(%[\dA-F]{2})+/gi, window.decodeURIComponent);
value = (cookie && cookie[2]) ? cookie[2] : value;

return value.toString().replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
}

/**
Expand Down Expand Up @@ -105,8 +106,8 @@ export default class Cookie
*/
_qualify(key)
{
return window.encodeURIComponent(this.namespace + key)
return encodeURIComponent(this.namespace + key)
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
.replace(/%(2[346B]|5E|60|7C)/g, window.decodeURIComponent);
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@conedevelopment/qkie",
"version": "1.2.0",
"version": "1.2.1",
"description": "Simple cookie management.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 66a660e

Please sign in to comment.