| 509 | // Strip ALL query params from a final URL before writing it back. Redirect-added |
| 510 | // params are nearly always tracking/session noise that shouldn't end up persisted. |
| 511 | function cleanFinalUrl(url) { |
| 512 | const u = safeUrl(url); |
| 513 | if (!u) return url; |
| 514 | u.search = ''; |
| 515 | u.hash = ''; |
| 516 | if ((u.protocol === 'https:' && u.port === '443') || (u.protocol === 'http:' && u.port === '80')) u.port = ''; |
| 517 | return u.href; |
| 518 | } |
| 519 | |
| 520 | // Apply only the safest changes: |
| 521 | // - Remove parked-domain profiles (eco-mind pattern) |