From 0e8b5a338882f1b335d3ebf7cedcb38b9549ff4f Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Sun, 16 Jun 2024 16:53:43 +0100 Subject: [PATCH] feat(cache): cosmetic cache validation logic The cache validation logic in `getCache` function has been updated. Previously, it returned the cache data if it ended with `hashComment`. Now, it returns null if the data does not end with `hashComment`, indicating that it's not a valid cache. This change improves the accuracy of cache validation. --- packages/unplugin-typia/src/core/cache.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/unplugin-typia/src/core/cache.ts b/packages/unplugin-typia/src/core/cache.ts index e55df0be..3d92be3b 100644 --- a/packages/unplugin-typia/src/core/cache.ts +++ b/packages/unplugin-typia/src/core/cache.ts @@ -51,11 +51,12 @@ export async function getCache( const hashComment = await getHashComment(key); - if (data.endsWith(hashComment)) { - return wrap(data); + /* if data does not end with hashComment, the cache is invalid */ + if (!data.endsWith(hashComment)) { + return null; } - return null; + return wrap(data); } /**