aboutsummaryrefslogtreecommitdiff
path: root/webAO/utils/getCookie.ts
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2023-09-20 12:57:45 +0200
committerstonedDiscord <Tukz@gmx.de>2023-09-20 12:57:45 +0200
commit59028dd4046ad0715d80be8d1ed0031f20f05b7a (patch)
treec66c470ad4fb959b8959f1895e410762c557437b /webAO/utils/getCookie.ts
parentef28c355ef69fee7511956751bbdb5dcd1a931b1 (diff)
mostly whitespaces, please don't break
Diffstat (limited to 'webAO/utils/getCookie.ts')
-rw-r--r--webAO/utils/getCookie.ts36
1 files changed, 18 insertions, 18 deletions
diff --git a/webAO/utils/getCookie.ts b/webAO/utils/getCookie.ts
index f5b9679..638dcb7 100644
--- a/webAO/utils/getCookie.ts
+++ b/webAO/utils/getCookie.ts
@@ -2,25 +2,25 @@
* read a cookie from storage
* got this from w3schools
* https://www.w3schools.com/js/js_cookies.asp
- * @param {String} cname The name of the cookie to return
+ * @param {string} cname The name of the cookie to return
*/
-const getCookie = (cname: String) => {
- try {
- const name = `${cname}=`;
- const decodedCookie = decodeURIComponent(document.cookie);
- const ca = decodedCookie.split(';');
- for (let i = 0; i < ca.length; i++) {
- let c = ca[i];
- while (c.charAt(0) === ' ') {
- c = c.substring(1);
- }
- if (c.indexOf(name) === 0) {
- return c.substring(name.length, c.length);
- }
+const getCookie = (cname: string) => {
+ try {
+ const name = `${cname}=`;
+ const decodedCookie = decodeURIComponent(document.cookie);
+ const ca = decodedCookie.split(';');
+ for (let i = 0; i < ca.length; i++) {
+ let c = ca[i];
+ while (c.charAt(0) === ' ') {
+ c = c.substring(1);
+ }
+ if (c.indexOf(name) === 0) {
+ return c.substring(name.length, c.length);
+ }
+ }
+ return '';
+ } catch (error) {
+ return '';
}
- return '';
- } catch (error) {
- return '';
- }
};
export default getCookie;