@@ -278,10 +278,36 @@ struct OperationsURLRoutingTests {
278278 #expect( OperationsDomainConfigPolicy . action ( for: " " , currentlyStored: " https://old.ru " ) == . clear)
279279 }
280280
281+ @Test ( " Policy — clears on whitespace-only string when something is stored (Android parity) " )
282+ func policyClearsOnWhitespaceWhenStored( ) {
283+ #expect( OperationsDomainConfigPolicy . action ( for: " " , currentlyStored: " https://old.ru " ) == . clear)
284+ #expect( OperationsDomainConfigPolicy . action ( for: " \t \n " , currentlyStored: " https://old.ru " ) == . clear)
285+ }
286+
281287 @Test ( " Policy — no-ops when nothing stored and nothing came " )
282288 func policyKeepsOnNothingToChange( ) {
283289 #expect( OperationsDomainConfigPolicy . action ( for: nil , currentlyStored: nil ) == . keep)
284290 #expect( OperationsDomainConfigPolicy . action ( for: " " , currentlyStored: nil ) == . keep)
291+ #expect( OperationsDomainConfigPolicy . action ( for: " " , currentlyStored: nil ) == . keep)
292+ }
293+
294+ @Test ( " Policy — trims surrounding whitespace before evaluating value " )
295+ func policyTrimsSurroundingWhitespace( ) {
296+ // Trimmed value matches stored after canonicalization → no-op.
297+ #expect(
298+ OperationsDomainConfigPolicy . action ( for: " anonymizer.client.ru " , currentlyStored: " https://anonymizer.client.ru " )
299+ == . keep
300+ )
301+ // Trimmed value differs from stored → save canonical form.
302+ #expect(
303+ OperationsDomainConfigPolicy . action ( for: " new.client.ru " , currentlyStored: " https://old.ru " )
304+ == . save( " https://new.client.ru " )
305+ )
306+ // Trimmed value with nothing stored → save canonical form.
307+ #expect(
308+ OperationsDomainConfigPolicy . action ( for: " valid.host.ru " , currentlyStored: nil )
309+ == . save( " https://valid.host.ru " )
310+ )
285311 }
286312
287313 @Test ( " Policy — rejects format-broken incoming value (previous kept intact) " )
0 commit comments