Skip to content

Commit 0368e77

Browse files
committed
chore: lint
1 parent 8c7dbf7 commit 0368e77

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

lib/utils/exchangeAuthCode.test.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
22
import { exchangeAuthCode } from ".";
33
import { MemoryStorage, StorageKeys } from "../sessionManager";
4-
import { setActiveStorage, clearActiveStorage, clearInsecureStorage } from "./token";
4+
import {
5+
setActiveStorage,
6+
clearActiveStorage,
7+
clearInsecureStorage,
8+
} from "./token";
59
import createFetchMock from "vitest-fetch-mock";
610
import { frameworkSettings } from "./exchangeAuthCode";
711
import * as refreshTokenTimer from "./refreshTimer";
@@ -412,7 +416,6 @@ describe("exchangeAuthCode", () => {
412416
urlParams.append("state", "test");
413417
urlParams.append("code", "test");
414418

415-
416419
const result = await exchangeAuthCode({
417420
urlParams,
418421
domain: "test.com",
@@ -449,7 +452,6 @@ describe("exchangeAuthCode", () => {
449452
redirectURL: "test.com",
450453
});
451454
} catch (error) {
452-
453455
expect((error as Error).message).toBe("Fetch failed");
454456
}
455457
});

lib/utils/getCookie.ts

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
export function getCookie(name: string): string | null {
2-
const cookies = document.cookie.split(';');
3-
for (let i = 0; i < cookies.length; i++) {
4-
const cookie = cookies[i].trim();
5-
if (cookie.startsWith(name + '=')) {
6-
const cookieValue = cookie.substring(name.length + 1);
7-
const parts = cookieValue.split(';');
8-
let hasExpiration = false;
9-
for (let j = 0; j < parts.length; j++) {
10-
const part = parts[j].trim();
11-
if (part.startsWith('expires=')) {
12-
hasExpiration = true;
13-
const expirationDate = new Date(part.substring(8));
14-
if (expirationDate > new Date()) {
15-
return cookieValue || null; // Cookie is valid
16-
} else {
17-
return null; // Cookie is expired
18-
}
19-
}
20-
}
21-
if (!hasExpiration) {
22-
return cookieValue || null; // Cookie has no expiration, so it's valid
23-
}
2+
const cookies = document.cookie.split(";");
3+
for (let i = 0; i < cookies.length; i++) {
4+
const cookie = cookies[i].trim();
5+
if (cookie.startsWith(name + "=")) {
6+
const cookieValue = cookie.substring(name.length + 1);
7+
const parts = cookieValue.split(";");
8+
let hasExpiration = false;
9+
for (let j = 0; j < parts.length; j++) {
10+
const part = parts[j].trim();
11+
if (part.startsWith("expires=")) {
12+
hasExpiration = true;
13+
const expirationDate = new Date(part.substring(8));
14+
if (expirationDate > new Date()) {
15+
return cookieValue || null; // Cookie is valid
16+
} else {
17+
return null; // Cookie is expired
18+
}
2419
}
20+
}
21+
if (!hasExpiration) {
22+
return cookieValue || null; // Cookie has no expiration, so it's valid
23+
}
2524
}
26-
return null; // Cookie not found
25+
}
26+
return null; // Cookie not found
2727
}

0 commit comments

Comments
 (0)