@@ -170,16 +170,13 @@ async def stromer_get_code(self) -> None:
170170 url , data = data , headers = {"Referer" : url }, allow_redirects = False
171171 )
172172 next_loc = res .headers .get ("Location" )
173- LOGGER .error ("DEBUG location result %s" , await res .text ())
174- LOGGER .error ("DEBUG determined next location: %s" , next_loc )
175173
176174 next_url = f"{ self .base_url } { next_loc } "
177- LOGGER .error ("DEBUG next url: %s" , next_url )
175+ if not (next_loc .startswith ("/" ) or next_loc .startswith ("?" )):
176+ raise NextLocationError (f"Invalid next location: '{ next_loc } '. Expected start with '/' or '?'." )
178177
179178 res = await self ._websession .get (next_url , allow_redirects = False )
180179 self ._code = res .headers .get ("Location" )
181- LOGGER .error ("DEBUG code result %s" , await res .text ())
182- LOGGER .error ("DEBUG code determined: %s" , self ._code )
183180 self ._code = self ._code .split ("=" )[1 ] # type: ignore[union-attr]
184181
185182 async def stromer_get_access_token (self ) -> None :
@@ -265,3 +262,6 @@ async def stromer_call_api(self, endpoint: str, full=False) -> Any:
265262
266263class ApiError (Exception ):
267264 """Error to indicate something wrong with the API."""
265+
266+ class NextLocationError (Exception ):
267+ """Error to indicate something wrong returned in next location."""
0 commit comments