From 9d1d5f9839e0f60366028e6f6d213edc82b521aa Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 27 Jan 2024 07:36:58 -0500 Subject: [PATCH] Support 'week' unit in `! Expires: ` directive --- src/js/assets.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/js/assets.js b/src/js/assets.js index 351cb9d0b..5a550dfb4 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -53,10 +53,13 @@ let remoteServerFriendly = false; const stringIsNotEmpty = s => typeof s === 'string' && s !== ''; const parseExpires = s => { - const matches = s.match(/(\d+)\s*([dhm]?)/i); + const matches = s.match(/(\d+)\s*([wdhm]?)/i); if ( matches === null ) { return; } let updateAfter = parseInt(matches[1], 10); - if ( matches[2] === 'h' ) { + if ( updateAfter === 0 ) { return; } + if ( matches[2] === 'w' ) { + updateAfter *= 7 * 24; + } else if ( matches[2] === 'h' ) { updateAfter = Math.max(updateAfter, 4) / 24; } else if ( matches[2] === 'm' ) { updateAfter = Math.max(updateAfter, 240) / 1440;