You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered inconsistent behavior in the library when a trailing slash is present in the URL during the authentication process. Specifically, the behavior differs depending on the authentication method used.
Issue Details
In all following explanation, hass_url is the machine hass url and port
With Normal Authentication: The library functions correctly both with and without a trailing slash in the URL. For example, http://hass_url and http://hass_url/ both work as expected.
With Long Lived Tokens: The library fails to authenticate when the URL includes a trailing slash. For example, http://hass_url/ does not work (further connection returns 404 error code), whereas http://hass_url works correctly.
Steps to Reproduce
Use the normal authentication method with the URL http://hass_url/ with trailing slash – Observe that it succeeds.
Use the normal authentication method with the URL http://hass_url without trailing slash – Observe that it succeeds.
Use authentication with long-lived tokens with the URL http://hass_url/ with trailing slash – Observe that it fails.
Use authentication with long-lived tokens with the URL http://hass_url without trailing slash – Observe that it succeeds.
Code :
// shared variablesconstHASS_URL_WITHOUT_TRAILING_SLASH="your_hass_url";constHASS_URL_WITH_TRAILING_SLASH="yout_hass_url/";letauth;// 1 and 2auth=awaitgetAuth({hassUrl: HASS_URL_WITH_TRAILING_SLASH});// further connection will worksauth=awaitgetAuth({hassUrl: HASS_URL_WITHOUT_TRAILING_SLASH});// further connection will works// 3 and 4constACCESS_TOKEN="your_access_token";auth=createLongLivedTokenAuth(HASS_URL_WITH_TRAILING_SLASH,ACCESS_TOKEN);// further connection will NOT worksauth=createLongLivedTokenAuth(HASS_URL_WITHOUT_TRAILING_SLASH,ACCESS_TOKEN);// further connection will works// shared further connectionconstconn=awaitcreateConnection({auth: auth});
Expected Behavior
The library should consistently handle URLs with or without a trailing slash in both authentication methods.
Actual Behavior
The library only fails with a trailing slash in the URL when using authentication with long-lived tokens (further connection returns 404 error code).
Description
I've encountered inconsistent behavior in the library when a trailing slash is present in the URL during the authentication process. Specifically, the behavior differs depending on the authentication method used.
Issue Details
In all following explanation,
hass_url
is the machine hass url and porthttp://hass_url
andhttp://hass_url/
both work as expected.http://hass_url/
does not work (further connection returns 404 error code), whereashttp://hass_url
works correctly.Steps to Reproduce
http://hass_url/
with trailing slash – Observe that it succeeds.http://hass_url
without trailing slash – Observe that it succeeds.http://hass_url/
with trailing slash – Observe that it fails.http://hass_url
without trailing slash – Observe that it succeeds.Code :
Expected Behavior
The library should consistently handle URLs with or without a trailing slash in both authentication methods.
Actual Behavior
The library only fails with a trailing slash in the URL when using authentication with long-lived tokens (further connection returns 404 error code).
Environment
Library version: 8.2.0
Environment/OS: Ubuntu 23.04
Thanks a lot for your nice lib :)
The text was updated successfully, but these errors were encountered: