-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Checks for IE11 localStorage (#54)
Related-to: OKTA-105205
- Loading branch information
1 parent
562bf86
commit 8177501
Showing
9 changed files
with
185 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
var cookies = require('./cookies'); | ||
var storageBuilder = require('./storageBuilder'); | ||
var config = require('./config'); | ||
|
||
// Building this as an object allows us to mock the functions in our tests | ||
var storageUtil = {}; | ||
|
||
// IE11 bug that Microsoft doesn't plan to fix | ||
// https://connect.microsoft.com/IE/Feedback/Details/1496040 | ||
storageUtil.browserHasLocalStorage = function() { | ||
try { | ||
if (storageUtil.getLocalStorage()) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} catch (e) { | ||
return false; | ||
} | ||
}; | ||
|
||
storageUtil.browserHasSessionStorage = function() { | ||
try { | ||
if (storageUtil.getSessionStorage()) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} catch (e) { | ||
return false; | ||
} | ||
}; | ||
|
||
storageUtil.getHttpCache = function() { | ||
if (storageUtil.browserHasLocalStorage()) { | ||
return storageBuilder(storageUtil.getLocalStorage(), config.CACHE_STORAGE_NAME); | ||
} else if (storageUtil.browserHasSessionStorage()) { | ||
return storageBuilder(storageUtil.getSessionStorage(), config.CACHE_STORAGE_NAME); | ||
} else { | ||
return storageBuilder(storageUtil.getCookieStorage(), config.CACHE_STORAGE_NAME); | ||
} | ||
}; | ||
|
||
storageUtil.getLocalStorage = function() { | ||
return localStorage; | ||
}; | ||
|
||
storageUtil.getSessionStorage = function() { | ||
return sessionStorage; | ||
}; | ||
|
||
// Provides webStorage-like interface for cookies | ||
storageUtil.getCookieStorage = function() { | ||
return { | ||
getItem: cookies.getCookie, | ||
setItem: function(key, value) { | ||
// Cookie shouldn't expire | ||
cookies.setCookie(key, value, '2038-01-19T03:14:07.000Z'); | ||
} | ||
}; | ||
}; | ||
|
||
module.exports = storageUtil; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters