Skip to content

Commit 9f7b5b8

Browse files
committed
Add extra comments
1 parent 0d31cd9 commit 9f7b5b8

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

library/helpers/safeDecodeURIComponent.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ const HEX = {
6161
* Decodes a URI component, returning undefined if the URI is invalid.
6262
* This function is a safe alternative to `decodeURIComponent`, which throws
6363
* an error if the URI is malformed.
64+
*
65+
* We use this for performance reasons (throwing errors is very slow).
6466
*/
6567
export function safeDecodeURIComponent(uri: string): string | undefined {
6668
let percentPosition = uri.indexOf("%");

library/sources/http-server/checkIfRequestIsBlocked.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ const checkedBlocks = Symbol("__zen_checked_blocks__");
1414
* - Whether the user agent is blocked by a user agent blocklist
1515
*/
1616
export function checkIfRequestIsBlocked(
17+
// We use a Symbol to store a boolean on the response object
18+
// So that we are the only ones who can access it
19+
// This boolean flag is used to determine whether the request has already been checked
1720
res: ServerResponse & { [checkedBlocks]?: boolean },
1821
agent: Agent
1922
): boolean {

0 commit comments

Comments
 (0)