From b09a9be37e3a48807f5e13a5ba877672d55ef4b8 Mon Sep 17 00:00:00 2001 From: Zarif Latif <102543743+zariffromlatif@users.noreply.github.com> Date: Thu, 27 Aug 2026 00:33:11 +0600 Subject: [PATCH] fix(sessions): support cross-platform path separators in is_anonymous_session --- httpie/sessions.py | 2 +- tests/test_sessions.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/httpie/sessions.py b/httpie/sessions.py index 99dcdba92e..ffc134d12c 100644 --- a/httpie/sessions.py +++ b/httpie/sessions.py @@ -40,7 +40,7 @@ def is_anonymous_session(session_name: str) -> bool: - return os.path.sep in session_name + return os.path.sep in session_name or bool(os.path.altsep and os.path.altsep in session_name) def session_hostname_to_dirname(hostname: str, session_name: str) -> str: diff --git a/tests/test_sessions.py b/tests/test_sessions.py index aa5243487d..690c0aa36d 100644 --- a/tests/test_sessions.py +++ b/tests/test_sessions.py @@ -850,3 +850,11 @@ def test_secure_cookies_on_localhost(mock_env, tmp_path, server, expected_cookie server + '/cookies' ) assert r.json == {'cookies': expected_cookies} + + +def test_is_anonymous_session_cross_platform(): + from httpie.sessions import is_anonymous_session + assert is_anonymous_session('custom/path/session.json') + assert is_anonymous_session('custom\\path\\session.json') + assert not is_anonymous_session('my_named_session') +