From 1f40fcb91a10cbd1a2583fff9fc09d66ec140b2d Mon Sep 17 00:00:00 2001 From: Ethan Marsh Date: Thu, 19 Mar 2020 12:13:40 -0700 Subject: [PATCH] fix(cookies): set default cookie path to / --- .size-snapshot.json | 20 ++++++++++---------- integration/fixtures/streamsql.min.js | 2 +- src/Cookies.ts | 2 ++ src/test/cookies.test.ts | 8 ++++++++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.size-snapshot.json b/.size-snapshot.json index 679b06a..2297646 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -1,26 +1,26 @@ { "dist/streamsql.esm.js": { - "bundled": 8662, - "minified": 4273, - "gzipped": 1705, + "bundled": 8725, + "minified": 4301, + "gzipped": 1721, "treeshaked": { "rollup": { "code": 75, "import_statements": 0 }, "webpack": { - "code": 4866 + "code": 4894 } } }, "dist/streamsql.cjs.js": { - "bundled": 10213, - "minified": 4843, - "gzipped": 1782 + "bundled": 10276, + "minified": 4871, + "gzipped": 1798 }, "dist/streamsql.min.js": { - "bundled": 11154, - "minified": 4647, - "gzipped": 1748 + "bundled": 11227, + "minified": 4675, + "gzipped": 1765 } } diff --git a/integration/fixtures/streamsql.min.js b/integration/fixtures/streamsql.min.js index e0d506a..dcb4fc0 100644 --- a/integration/fixtures/streamsql.min.js +++ b/integration/fixtures/streamsql.min.js @@ -1 +1 @@ -!function(t){"function"==typeof define&&define.amd?define("streamsql",t):t()}((function(){"use strict";var t,e=function(t){return new Error("[StreamSQL] Error: "+t)},i=function(t){return t&&t.length?t[0].toUpperCase()+t.slice(1).toLowerCase():t},n=function(){function t(t,e){this.url=t,this.apiKey=e,this.xhr=void 0,this.xhr=this.buildRequest(this.url,this.apiKey)}var i=t.prototype;return i.send=function(t,i){var n=this;return this.xhr=this.buildRequest(this.url,this.apiKey),new Promise((function(r,s){n.xhr.onreadystatechange=function(){if(this.readyState===this.DONE)if(i&&i(this.status,this.responseText),this.status>=200&&this.status<400)try{r(this.response)}catch(t){s(t)}else if(this.status)try{s(this.response)}catch(t){s(t)}else s(e("something went wrong sending XMLHttpRequest"))};try{n.xhr.send(JSON.stringify(t))}catch(t){s(t)}}))},i.buildRequest=function(t,e){var i=new XMLHttpRequest;return i.open("POST",t,!0),i.setRequestHeader("Content-Type","application/json; charset=UTF-8"),i.setRequestHeader("x-streamsql-key",e),i.withCredentials=!0,i.timeout=3e3,i},t}();!function(t){t.None="None",t.Lax="Lax",t.Strict="Strict"}(t||(t={}));var r=function(){function e(){this.simpleCookies=new Map}var n=e.prototype;return n.setCookie=function(e){if(!e.maxAge&&!e.expires){var i=new Date;i.setFullYear(i.getFullYear()+1),e.expires=i.toUTCString()}e.secure=!0,e.sameSite=t.None,this.simpleCookies.set(e.name,e.value),document.cookie=this.toCookieString(e)},n.getCookie=function(t){if(this.simpleCookies.has(t))return this.simpleCookies.get(t);var e="";try{for(var i=t+"=",n=document.cookie.split(";"),r=0;r=200&&this.status<400)try{r(this.response)}catch(t){s(t)}else if(this.status)try{s(this.response)}catch(t){s(t)}else s(e("something went wrong sending XMLHttpRequest"))};try{n.xhr.send(JSON.stringify(t))}catch(t){s(t)}}))},i.buildRequest=function(t,e){var i=new XMLHttpRequest;return i.open("POST",t,!0),i.setRequestHeader("Content-Type","application/json; charset=UTF-8"),i.setRequestHeader("x-streamsql-key",e),i.withCredentials=!0,i.timeout=3e3,i},t}();!function(t){t.None="None",t.Lax="Lax",t.Strict="Strict"}(t||(t={}));var r=function(){function e(){this.simpleCookies=new Map}var n=e.prototype;return n.setCookie=function(e){if(!e.maxAge&&!e.expires){var i=new Date;i.setFullYear(i.getFullYear()+1),e.expires=i.toUTCString()}e.path=e.path||"/",e.secure=!0,e.sameSite=t.None,this.simpleCookies.set(e.name,e.value),document.cookie=this.toCookieString(e)},n.getCookie=function(t){if(this.simpleCookies.has(t))return this.simpleCookies.get(t);var e="";try{for(var i=t+"=",n=document.cookie.split(";"),r=0;r { expect(document.cookie).toMatch('Secure') }) + it('sets default cookie path to /', () => { + ch.setCookie({ + name: 'name', + value: 'value', + }) + expect(document.cookie).toMatch('Path=/') + }) + it('overrides default domain and path when set in options', () => { ch.setCookie({ name: 'name',