Skip to content

Commit

Permalink
chore: change UUID name
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcastrodev committed Sep 29, 2023
1 parent 16c1e9e commit 7ea4df6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/StaticRenderRegeneration/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CacheManager } from "./cache_manager.ts";
import { StaticRegenerationOptions } from "./types.ts";
import { generateUUID, getUrl, readCache } from "./utils.ts";
import { getUrl, hashString, readCache } from "./utils.ts";

export async function staticRenderRegeneration(
request: Request,
Expand All @@ -15,7 +15,7 @@ export async function staticRenderRegeneration(
return await render(request);
}

const cacheFile = await generateUUID(url.pathname + (url.search ?? ""));
const cacheFile = await hashString(url.pathname + (url.search ?? ""));
const cacheManager = new CacheManager(options.revalidate ?? 0, cacheFile);
if (cacheManager.isCacheValid) {
const cache = readCache(cacheManager.cacheFilePath);
Expand Down
2 changes: 1 addition & 1 deletion src/StaticRenderRegeneration/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function readCache(cacheFilePath: string): Uint8Array | null {
}

// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
export async function generateUUID(message: string): Promise<string> {
export async function hashString(message: string): Promise<string> {
const encoder = new TextEncoder();
const data = encoder.encode(message);
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
Expand Down

0 comments on commit 7ea4df6

Please sign in to comment.