Skip to content

Commit

Permalink
fix(Cookie): Bug on main domain
Browse files Browse the repository at this point in the history
Cookie storage work incorrectly on main domain

fix #6
  • Loading branch information
CrazySquirrel committed Jun 19, 2018
1 parent 9f71a6e commit 8be02b4
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 3 deletions.
3 changes: 3 additions & 0 deletions interfaces/IDebug.d.ts
Expand Up @@ -111,4 +111,7 @@ interface IDebug {
*/
_debug(strMessage: any, ...AdditionalMessage: Array<any>): void;
}
/**
* Export the IDebug interface
*/
export default IDebug;
3 changes: 3 additions & 0 deletions interfaces/ILocalStorage.d.ts
Expand Up @@ -28,4 +28,7 @@ interface ILocalStorage {
*/
removeItem(key: string): void;
}
/**
* Export the ILocalStorage interface
*/
export default ILocalStorage;
3 changes: 3 additions & 0 deletions interfaces/ISessionStorage.d.ts
Expand Up @@ -28,4 +28,7 @@ interface ISessionStorage {
*/
removeItem(key: string): void;
}
/**
* Export the ISessionStorage interface
*/
export default ISessionStorage;
3 changes: 3 additions & 0 deletions interfaces/IStorage.d.ts
Expand Up @@ -46,4 +46,7 @@ interface IStorage {
*/
clear(checkSupport: boolean): boolean;
}
/**
* Export the IStorage interface
*/
export default IStorage;
3 changes: 3 additions & 0 deletions interfaces/IWindow.d.ts
Expand Up @@ -27,4 +27,7 @@ interface IWindow {
Debug: IDebug;
setTimeout(callback: Function, time: number): number;
}
/**
* Export the window interface
*/
export default IWindow;
2 changes: 1 addition & 1 deletion lib/EverCookie.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/Storages/Cookies.js

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

6 changes: 5 additions & 1 deletion lib/Storages/Cookies.ts
Expand Up @@ -51,9 +51,13 @@ export default class Cookies implements IStorage {
value: string,
expires: number = 30,
path: string = "/",
domain: string = "." + location.hostname.split(".").slice(-2).join("."),
domain: string = "",
secure: boolean = (location.protocol === "https:")): boolean {
try {
if (!domain) {
const d = location.hostname.split(".");
domain = (d.length > 2 ? "." : "") + d.join(".");
}
/**
* Validate input data
*/
Expand Down
1 change: 1 addition & 0 deletions spec/Cookie.spec.d.ts
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions spec/DOMStorage.spec.d.ts
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions spec/EverCookie.spec.d.ts
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions spec/GlobalStorage.spec.d.ts
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions spec/LocalStorage.spec.d.ts
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions spec/SessionStorage.spec.d.ts
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions src/simple-typescript-example/index.d.ts
@@ -0,0 +1 @@
export {};

0 comments on commit 8be02b4

Please sign in to comment.