Skip to content

Commit

Permalink
Project update. [p][robotic]
Browse files Browse the repository at this point in the history
  • Loading branch information
jaswrks committed Mar 16, 2024
1 parent f74abe5 commit d452d48
Show file tree
Hide file tree
Showing 23 changed files with 211 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .browserslistrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Mar 15, 2024 8:58 AM UTC.
# Last generated Mar 16, 2024 2:55 AM UTC.

[production]
node >= 20.9.0
Expand Down
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Mar 15, 2024 8:58 AM UTC.
# Last generated Mar 16, 2024 2:55 AM UTC.

# Locals

Expand Down
8 changes: 4 additions & 4 deletions .env.vault
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ DOTENV_VAULT_MAIN="7GW98NfL4hM4N6HbfeDXCKreVxKvcVPupFRnZ8XJ+pomaQ=="
DOTENV_VAULT_MAIN_VERSION=1

# dev
DOTENV_VAULT_DEV="574ELXrHj4VNmUqsDYhwbpFmWitCsN4euV5UwniYcmb7q5lRqStjSjhVpYlKBNI/k+t0HaHFrR3s7yt0z4X/qfIGSkLe/xhmcawcy7BiAGHP6PKQFO2TEHTCIZNLDtGqzrq+x6WpteqCA8Yejy9O71b8d71ZyjPJw9zbjJB2g3pEsVX2LCcPjrY7MxhtlcyjI/NB1YdZnm8CjmVHsRz1WnBzLAcI4P6skAX7X9XX/FxSuKv8k63PmjakZWNob1/L7Q=="
DOTENV_VAULT_DEV_VERSION=457
DOTENV_VAULT_DEV="O9VkthkxvBAdSrwf1CVueZQ1uUKqItb92QthzejUPfShQlRmnhWTKVw7ZPdUht2t6qQakgeJQq2rpPGRpJmfz5STB5wMpm4kkVcaNnyOHUGI4bgL1bg5DeI+OSMbJ2Joso+gz9GqK82O9soqvCPiIBRTJywnoyjdALdP5O1NhOQnL2Hlz+iwWzQY0vgOCuttekAaMKx0oIAy7474OEibFPJ4fwFzlS2tlo2xR49BY6dgLU52QfpYcdl+ZtICk8ZHDA=="
DOTENV_VAULT_DEV_VERSION=459

# ci
DOTENV_VAULT_CI="HpoOuFIeKrVgWepRjdY69LajPpNahcqj+02jPeyuSPkJtq9afKnaXpzNOIL+pdtPXrphcl4GCIi42tt+NU9osiNC3GKLadr3P2rRZ6RP9C6Xb7+zuM0DFFPO+40Z0o1Bhw4fwPa1dNJgHStLaVztq8IQDJkuzUXq/iW9E4Hd7g=="
DOTENV_VAULT_CI_VERSION=457
DOTENV_VAULT_CI="RP4UxhHGgIQLX1irR/uSoRCpq2agnPvlZHBU8L3PmYpIYplqV8tMk00Z4Y6aIea84DFSaADdgbJ3YWr9mcLg645qdv++0cObwfi0XEygvyGuQe7b+jThzeZBTZ92CwFi11pSSo9u8zhOv9ildvJTNnzt3ms1kji3XRr14xBJOA=="
DOTENV_VAULT_CI_VERSION=459

# stage
DOTENV_VAULT_STAGE="aRP8su2YV4jZu3w1HZ/SLaots0IwJDFw75TCpvXEFeNp7tw="
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Mar 15, 2024 8:58 AM UTC.
# Last generated Mar 16, 2024 2:55 AM UTC.

# Default

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Mar 15, 2024 8:58 AM UTC.
# Last generated Mar 16, 2024 2:55 AM UTC.

# Locals

Expand Down
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Generated data.
# <generated:start>

# Last generated Mar 15, 2024 8:58 AM UTC.
# Last generated Mar 16, 2024 2:55 AM UTC.

# Locals

Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Mar 15, 2024 8:58 AM UTC.
# Last generated Mar 16, 2024 2:55 AM UTC.

# Packages

Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @note This entire file will be updated automatically.
* @note Instead of editing here, please review `./settings.mjs`.
*
* Last generated using `./settings.mjs` Mar 15, 2024 8:58 AM UTC.
* Last generated using `./settings.mjs` Mar 16, 2024 2:55 AM UTC.
*/
{
"editor.formatOnType": false,
Expand Down
2 changes: 1 addition & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Mar 15, 2024 8:58 AM UTC.
# Last generated Mar 16, 2024 2:55 AM UTC.

# Locals

Expand Down
128 changes: 94 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.0.915",
"version": "1.0.916",
"license": "GPL-3.0-or-later",
"name": "@clevercanyon/utilities",
"description": "Utilities for JavaScript apps running in any environment.",
Expand Down
14 changes: 11 additions & 3 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,28 @@ export const prepareRequest = async (request: $type.Request, config?: RequestCon
/**
* Produces a hash of a given HTTP request.
*
* Properties and headers are sorted for hash consistency.
* Properties, headers, and URL query vars are sorted for consistency. We hash a canonicalized URL; i.e., without query
* vars and/or a #hash. Query vars are hashed separately and any #hash value is ignored entirely. Query vars are hashed
* as decoded entries, such that we avoid encoding discrepancies across platforms; e.g., {@see https://o5p.me/mwt0RQ}.
*
* @param request HTTP request.
*
* @returns SHA-1 hash of HTTP request.
*
* @note Please {@see requestPropertyDefaults()}, which makes hashing possible.
* @see requestPropertyDefaults(), which is what makes hashing possible.
*/
export const requestHash = $fnꓺmemo(2, async (request: $type.Request): Promise<string> => {
const defaults = requestPropertyDefaults(),
const url = new URL(request.url),
defaults = requestPropertyDefaults(),
properties = requestProperties(request),
unsortedProps = $obj.defaults(properties, defaults) as $type.StrKeyable;

const sortedProps = Object.fromEntries([...Object.entries(unsortedProps)].sort((a, b) => a[0].localeCompare(b[0])));

sortedProps.url = {
canonical: $url.toCanonical(url), // i.e., Without ?query and/or #hash.
queryVars: [...url.searchParams.entries()].sort((a, b) => a[0].localeCompare(b[0])),
};
sortedProps.headers = [...request.headers.entries()].sort((a, b) => a[0].localeCompare(b[0]));

if (sortedProps.body /* Requires request clone. */) {
Expand Down
6 changes: 3 additions & 3 deletions src/tests/classes/fetcher/index.cfw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ describe('Fetcher', async () => {
headers: { 'content-type': $mime.contentType('.txt') },
},
};
expect(fetcher.global.cache['ccb3b1f7061e279e02f9d3761d0dcf90ced8e4b8']).toStrictEqual(expectedCache);
expect(fetcher.global.cache['e42f835c52038a7a9f0d37f1e570d0f573185ecd']).toStrictEqual(expectedCache);
expect(fetcher.global.cache['cca6054445f5e17c31218d204a66bbabba314234']).toStrictEqual(expectedCache);
expect(fetcher.global.cache['dea440f47ad1caee47a54e1d9caebc4ee4829de5']).toStrictEqual(expectedCache);
expect(fetcher.global.cache['6e589b81c89bc2c5c7d1a20cd59fb92c2be5b08a']).toStrictEqual(expectedCache);
expect(fetcher.global.cache['d07c269b27b019bd5dd5c22bec9795e437eca3e7']).toStrictEqual(expectedCache);
});
});
6 changes: 3 additions & 3 deletions src/tests/classes/fetcher/index.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ describe('Fetcher', async () => {
headers: { 'content-type': $mime.contentType('.txt') },
},
};
expect(fetcher.global.cache['ccb3b1f7061e279e02f9d3761d0dcf90ced8e4b8']).toStrictEqual(expectedCache);
expect(fetcher.global.cache['e42f835c52038a7a9f0d37f1e570d0f573185ecd']).toStrictEqual(expectedCache);
expect(fetcher.global.cache['cca6054445f5e17c31218d204a66bbabba314234']).toStrictEqual(expectedCache);
expect(fetcher.global.cache['dea440f47ad1caee47a54e1d9caebc4ee4829de5']).toStrictEqual(expectedCache);
expect(fetcher.global.cache['6e589b81c89bc2c5c7d1a20cd59fb92c2be5b08a']).toStrictEqual(expectedCache);
expect(fetcher.global.cache['d07c269b27b019bd5dd5c22bec9795e437eca3e7']).toStrictEqual(expectedCache);
});
});
Loading

0 comments on commit d452d48

Please sign in to comment.