Skip to content

Commit fe1cd22

Browse files
authored
Added strip() to chess usesrname string input. (#8)
1 parent 9b7698b commit fe1cd22

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

checkmymate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def home():
1515

1616
# get field values from the form
1717
chess_username = request.form["chess_username"]
18-
chess_username = chess_username if chess_username else " "
18+
chess_username = chess_username.strip() if chess_username else " " # Clean the string input with .strip().
1919
num_lookback_days = request.form["num_lookback_days"]
2020
platform = request.form["platform"]
2121
logger.debug(f"platform: {platform}")

utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def is_lichess_user(lichess_username):
123123

124124

125125
def is_chessdotcom_user(chessdotcom_username):
126-
player_dict = json.loads(requests.get(f"https://api.chess.com/pub/player/{chessdotcom_username}").content)
126+
url = f"https://api.chess.com/pub/player/{chessdotcom_username}"
127+
player_dict = json.loads(requests.get(url).content)
127128
if "player_id" in player_dict:
128129
return True
129130
return False

0 commit comments

Comments
 (0)