Skip to content

Fix malformed URL when address contains trailing slash - #536

Merged
rroller merged 5 commits into
rroller:mainfrom
JoshDev:fix/url-construction-trailing-slash
Jan 7, 2026
Merged

Fix malformed URL when address contains trailing slash#536
rroller merged 5 commits into
rroller:mainfrom
JoshDev:fix/url-construction-trailing-slash

Conversation

@JoshDev

@JoshDev JoshDev commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes issue where configured address ending with trailing slash causes malformed URLs
  • Strips trailing slashes from address during initialization

Problem

When the address is entered with a trailing slash (e.g., 192.168.3.65/), the base URL is incorrectly constructed as:

http://192.168.3.65/:80/cgi-bin/eventManager.cgi

instead of:

http://192.168.3.65:80/cgi-bin/eventManager.cgi

This causes 404 errors on API calls.

Solution

Strip trailing slashes from the address when storing it in self._address. This also fixes the same potential issue in RTSP URL construction.

Test plan

  • Verify URL construction with normal address (e.g., 192.168.3.65)
  • Verify URL construction with trailing slash address (e.g., 192.168.3.65/)

Fixes #474

When the configured address ends with a trailing slash (e.g., 192.168.3.65/),
the base URL is incorrectly constructed as http://192.168.3.65/:80 instead of
http://192.168.3.65:80, causing 404 errors on API calls.

This fix strips trailing slashes from the address when storing it, which also
fixes the same potential issue in RTSP URL construction.

Fixes rroller#474
@JoshDev

JoshDev commented Jan 6, 2026

Copy link
Copy Markdown
Contributor Author

Note: The CI test failure is a pre-existing issue unrelated to this PR. The requirements_test.txt pins pytest-homeassistant-custom-component==0.13.286 which requires Python 3.13+, but the CI workflow runs Python 3.12. The main branch has been failing with the same error since November 2024.

pytest-homeassistant-custom-component==0.13.286 requires Python 3.13+
pytest-homeassistant-custom-component 0.13.286 has dependency issues with
Python 3.13 (aiodns/pycares incompatibility). Using 0.13.205 which is the
latest version compatible with Python 3.12.
pycares 5.0 has breaking API changes that aiodns hasn't adapted to yet.
Pin to pycares 4.x to resolve the AttributeError with ares_query_a_result.

See: home-assistant/core#158695
- Add conftest.py to load pytest-homeassistant-custom-component fixtures
- Add pytest.ini with asyncio_mode=auto for async test support
@JoshDev

JoshDev commented Jan 6, 2026

Copy link
Copy Markdown
Contributor Author

The CI is fixed now.

@rroller

rroller commented Jan 7, 2026

Copy link
Copy Markdown
Owner

Thank you!

@rroller
rroller merged commit 9f68efa into rroller:main Jan 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

404 in a eventManager.cgi attach call - incorrect url construction

2 participants