string.lstrip(str) strips from the start of string any number of characters which match the characters in str. It does not strip from the start of string the string str. The result of the current code is that if the Twitch API returns the bearer token without the word Bearer at the start (which in my experience is, in fact, the case) then any characters in the word 'Bearer' will be stripped from the start of the actual bearer token.
Given this is not the intended behaviour, this pull request proposes to instead check if the API has returned a string starting with Bearer, and if it has, to remove the first six characters from that string. This does, however, leave open a 1 in 2,176,782,336 chance that the actual bearer token starts with the characters bearer in that order, assuming this edge case isn't already filtered out by the Twitch API. Further work may be required.
string.lstrip(str)
strips from the start ofstring
any number of characters which match the characters instr
. It does not strip from the start ofstring
the stringstr
. The result of the current code is that if the Twitch API returns the bearer token without the wordBearer
at the start (which in my experience is, in fact, the case) then any characters in the word 'Bearer' will be stripped from the start of the actual bearer token.Given this is not the intended behaviour, this pull request proposes to instead check if the API has returned a string starting with
Bearer
, and if it has, to remove the first six characters from that string. This does, however, leave open a 1 in 2,176,782,336 chance that the actual bearer token starts with the charactersbearer
in that order, assuming this edge case isn't already filtered out by the Twitch API. Further work may be required.