Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to disable cookie processing altogether by setting cookie… #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theJC
Copy link

@theJC theJC commented Mar 6, 2023

…Jar to undefined in context

Fixes: #109

@@ -181,11 +181,14 @@ describe( `context (${version} over ${proto.replace( ":", "" )})`, ( ) =>
userAgent: "foobar",
} );

await fetch( `${proto}//localhost:${port}/set-cookie`, {
const response1 = await fetch( `${proto}//localhost:${port}/set-cookie`, {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor]: It's batter to avoid numbers in a variable name. It seems like a code smell. If you realised that you need more then one response, so just describe in the name of these responses what you expect.

@@ -41,10 +41,10 @@ export interface ServerOptions
export abstract class Server
{
public port: number | null = null;
public receivedCookies: Array<string> = new Array<string>();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor]: It is not a good idea to use constructors as types.

  • Some constructors, such as Object, Function, or Array, are very broad and do not provide much type safety or information. Using them as types can make the code less clear and more prone to bugs.
  • TypeScript has built-in types for primitive values, such as number, string, boolean, etc. Using constructors like Number, String, or Boolean as types can lead to unexpected behavior and type errors.
Suggested change
public receivedCookies: Array<string> = new Array<string>();
public receivedCookies: string[] = [];

@@ -310,11 +314,11 @@ export class ServerHttp1 extends TypedServer< HttpServer | HttpsServer >
}

export async function makeServer( opts: ServerOptions = { } )
: Promise< { server: Server; port: number | null; } >
: Promise< { server: Server; port: number | null; receivedCookies: Array<string> } >
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor]: As i described before use constructors as types is not a good idea.

Suggested change
: Promise< { server: Server; port: number | null; receivedCookies: Array<string> } >
: Promise< { server: Server; port: number | null; receivedCookies: string[] } >

@@ -360,11 +363,11 @@ export class ServerHttp2 extends TypedServer< Http2Server >
}

export async function makeServer( opts: ServerOptions = { } )
: Promise< { server: Server; port: number | null; } >
: Promise< { server: Server; port: number | null; receivedCookies: Array<string> } >
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor]: As i described before use constructors as types is not a good idea.

Suggested change
: Promise< { server: Server; port: number | null; receivedCookies: Array<string> } >
: Promise< { server: Server; port: number | null; receivedCookies: string[] } >

@@ -82,7 +82,7 @@ export class Context
private _userAgent: string | PerOrigin< string >;
private _overwriteUserAgent: boolean | PerOrigin< boolean >;
private _accept: string | PerOrigin< string >;
private _cookieJar: CookieJar;
private _cookieJar: undefined | CookieJar;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor]: since you need to use the same type in another place, so I would suggest that you make this an alias.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to disable cookies
1 participant