Improve `trusted-set-cookie` scriptlet

Replace placehoders instead of direct assignement

Related feedback:
https://github.com/uBlockOrigin/uAssets/pull/23877#issuecomment-2134417389
This commit is contained in:
Raymond Hill 2024-05-28 09:18:09 -04:00
parent d8a77f38ce
commit 0e1e4b82c5
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 5 additions and 4 deletions

View File

@ -4228,10 +4228,11 @@ function trustedSetCookie(
const logPrefix = safe.makeLogPrefix('set-cookie', name, value, path);
const time = new Date();
if ( value === '$now$' ) {
value = Date.now();
} else if ( value === '$currentDate$' ) {
value = time.toUTCString();
if ( value.includes('$now$') ) {
value = value.replaceAll('$now$', time.getTime());
}
if ( value.includes('$currentDate$') ) {
value = value.replaceAll('$currentDate$', time.toUTCString());
}
let expires = '';