Skip to content

Commit 44bff53

Browse files
committed
Update CookieManager.ts
1 parent 1ffe81f commit 44bff53

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/@hprose/rpc-core/src/CookieManager.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
| |
99
| CookieManager for TypeScript. |
1010
| |
11-
| LastModified: Jan 10, 2019 |
11+
| LastModified: Dec 18, 2019 |
1212
| Author: Ma Bingyao <[email protected]> |
1313
| |
1414
\*________________________________________________________*/
1515

1616
const cookieManager = Object.create(null);
1717

18-
export function setCookie(headers: { [header: string]: string | string[] | undefined }, host: string = '@'): void {
18+
export function setCookie(headers: { [header: string]: string | string[] | undefined }, host: string | null = '@'): void {
1919
function _setCookie(value?: string) {
2020
if (value === undefined) return;
2121
let cookies: string[] = value.trim().split(';');
@@ -57,7 +57,9 @@ export function setCookie(headers: { [header: string]: string | string[] | undef
5757
}
5858
}
5959

60-
export function getCookie(host: string = '@', path: string = '/', secure: boolean) {
60+
export function getCookie(host: string | null | undefined, path: string | null | undefined, secure: boolean) {
61+
host = host ?? '@';
62+
path = path ?? '/';
6163
let cookies: string[] = [];
6264
for (const domain in cookieManager) {
6365
if (host.indexOf(domain) > -1) {

0 commit comments

Comments
 (0)