Support 'week' unit in `! Expires: ` directive

This commit is contained in:
Raymond Hill 2024-01-27 07:36:58 -05:00
parent 7cd0ef6ab5
commit 9d1d5f9839
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 5 additions and 2 deletions

View File

@ -53,10 +53,13 @@ let remoteServerFriendly = false;
const stringIsNotEmpty = s => typeof s === 'string' && s !== ''; const stringIsNotEmpty = s => typeof s === 'string' && s !== '';
const parseExpires = s => { const parseExpires = s => {
const matches = s.match(/(\d+)\s*([dhm]?)/i); const matches = s.match(/(\d+)\s*([wdhm]?)/i);
if ( matches === null ) { return; } if ( matches === null ) { return; }
let updateAfter = parseInt(matches[1], 10); 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; updateAfter = Math.max(updateAfter, 4) / 24;
} else if ( matches[2] === 'm' ) { } else if ( matches[2] === 'm' ) {
updateAfter = Math.max(updateAfter, 240) / 1440; updateAfter = Math.max(updateAfter, 240) / 1440;