mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-28 15:31:11 -04:00
change(tracking): More broad userpage filter
This commit is contained in:
parent
1943d5d8fd
commit
0a5ea0cf25
@ -21,20 +21,23 @@ function redact(redactor, base = defaultHandler) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const USER_AT = /^\/@.+/;
|
||||||
|
const USER_SUBPAGE = /^\/(u|card)\/.*/;
|
||||||
|
|
||||||
const TRACKER_OVERRIDES = [
|
const TRACKER_OVERRIDES = [
|
||||||
{
|
{
|
||||||
test(v) {
|
test(v) {
|
||||||
return /^\/@.+/.test(v);
|
return USER_AT.test(v) || USER_SUBPAGE.test(v);
|
||||||
},
|
},
|
||||||
handling: redact((v) => {
|
handling: redact((v) => {
|
||||||
const parts = v.pathname.split('/').filter((v) => v.length > 0);
|
let pathname = v.pathname;
|
||||||
for (const i in parts) { // NOTE(tecc): This might be overengineering but that's fine
|
if (USER_AT.test(pathname)) {
|
||||||
const part = parts[i];
|
pathname = pathname.replace(USER_AT, '/@--redacted--')
|
||||||
if (/^@.+$/.test(part)) {
|
|
||||||
parts[i] = '@--redacted--';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
v.pathname = '/' + parts.join('/');
|
if (USER_SUBPAGE.test(pathname)) {
|
||||||
|
pathname = pathname.replace(USER_SUBPAGE, '/$1/--redacted--');
|
||||||
|
}
|
||||||
|
v.pathname = pathname;
|
||||||
return v;
|
return v;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user