From 7c77bf566e26aff0b3cf0be20df924c4a613b68b Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 11 Apr 2024 17:07:13 -0400 Subject: [PATCH] Remove quotes when processing etag --- src/middleware/etag.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/middleware/etag.ts b/src/middleware/etag.ts index abddc05..0e94d97 100644 --- a/src/middleware/etag.ts +++ b/src/middleware/etag.ts @@ -4,7 +4,7 @@ import { QueryCacher } from "../utils/queryCacher"; import { skipSegmentsHashKey, skipSegmentsKey, videoLabelsHashKey, videoLabelsKey } from "../utils/redisKeys"; type hashType = "skipSegments" | "skipSegmentsHash" | "videoLabel" | "videoLabelHash"; -type ETag = `${hashType};${VideoIDHash};${Service};${number}`; +type ETag = `"${hashType};${VideoIDHash};${Service};${number}"`; type hashKey = string | VideoID | VideoIDHash; export function cacheMiddlware(req: Request, res: Response, next: NextFunction): void { @@ -12,7 +12,7 @@ export function cacheMiddlware(req: Request, res: Response, next: NextFunction): // if weak etag, do not handle if (!reqEtag || reqEtag.startsWith("W/")) return next(); // split into components - const [hashType, hashKey, service, lastModified] = reqEtag.split(";"); + const [hashType, hashKey, service, lastModified] = reqEtag.replace(/^"|"$/g, "").split(";"); // fetch last-modified getLastModified(hashType as hashType, hashKey as VideoIDHash, service as Service) .then(redisLastModified => {