aboutsummaryrefslogtreecommitdiff
path: root/webAO/utils/getCookie.ts
diff options
context:
space:
mode:
authorstonedDiscord <stonedDiscord@users.noreply.github.com>2024-11-20 13:31:50 +0000
committerGitHub Action <actions@github.com>2024-11-20 13:31:50 +0000
commit6684f3fce6e90fd0574d7bab63b629554ab03ef6 (patch)
treeb2a62247d17e23a77af57aea355ba621666817c2 /webAO/utils/getCookie.ts
parent95a2d1361d84c61b454ebe506e6963b93f6d8dee (diff)
Prettified Code!
Diffstat (limited to 'webAO/utils/getCookie.ts')
-rw-r--r--webAO/utils/getCookie.ts32
1 files changed, 16 insertions, 16 deletions
diff --git a/webAO/utils/getCookie.ts b/webAO/utils/getCookie.ts
index 638dcb7..7373688 100644
--- a/webAO/utils/getCookie.ts
+++ b/webAO/utils/getCookie.ts
@@ -5,22 +5,22 @@
* @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);
- }
- }
- return '';
- } catch (error) {
- return '';
+ 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 "";
+ }
};
export default getCookie;