mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Improve trusted-set-cookie scriptlet
Ability to use regex value for `, domain, value` vararg.
Related discussion:
afc6ff52ff (commitcomment-160035082)
This commit is contained in:
parent
28d2326808
commit
3a2bb62519
1 changed files with 9 additions and 1 deletions
|
|
@ -135,7 +135,15 @@ export function setCookieFn(
|
|||
|
||||
if ( trusted ) {
|
||||
if ( options.domain ) {
|
||||
cookieParts.push(`; domain=${options.domain}`);
|
||||
let domain = options.domain;
|
||||
if ( /^\/.+\//.test(domain) ) {
|
||||
const reDomain = new RegExp(domain.slice(1, -1));
|
||||
const match = reDomain.exec(document.location.hostname);
|
||||
domain = match ? match[0] : undefined;
|
||||
}
|
||||
if ( domain ) {
|
||||
cookieParts.push(`; domain=${domain}`);
|
||||
}
|
||||
}
|
||||
cookieParts.push('; Secure');
|
||||
} else if ( /^__(Host|Secure)-/.test(name) ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue