-
Notifications
You must be signed in to change notification settings - Fork 15
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
base: master
Are you sure you want to change the base?
Conversation
…Jar to undefined in context
@@ -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`, { |
There was a problem hiding this comment.
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>(); |
There was a problem hiding this comment.
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.
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> } > |
There was a problem hiding this comment.
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.
: 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> } > |
There was a problem hiding this comment.
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.
: 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; |
There was a problem hiding this comment.
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.
…Jar to undefined in context
Fixes: #109