Skip to content

Commit

Permalink
Fix: check for URLs including trailing slash (#13)
Browse files Browse the repository at this point in the history
Although this is not really relevant in our case, LGTM rightfully
indicates that these 'startswith' can still have URLs like
'https://api.github.com.fake.domain', and validate. We of course
not as much use the validation to check if it really comes from
github.com, merely to ensure that the next statement is valid.
Nevertheless, it is a sane change to make.
  • Loading branch information
TrueBrain committed Jan 1, 2020
1 parent 6dd9a82 commit 25fbc55
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dorpsgek/events/commit_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async def commit_comment(event, github_api):
return

commits_url = event.data["repository"]["commits_url"]
assert commits_url.startswith("https://api.github.com")
assert commits_url.startswith("https://api.github.com/")
commits_url = commits_url[len("https://api.github.com"):]
assert commits_url.endswith("{/sha}")
commits_url = commits_url.replace("{/sha}", "/" + event.data["comment"]["commit_id"])
Expand Down
2 changes: 1 addition & 1 deletion dorpsgek/events/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def issue_comment(event, github_api):
# To not assume Pull Request are always against 'master',
# we take an extra roundtrip to find the base branch
pull_request_url = event.data["issue"]["pull_request"]["url"]
assert pull_request_url.startswith("https://api.github.com")
assert pull_request_url.startswith("https://api.github.com/")
pull_request_url = pull_request_url[len("https://api.github.com"):]
response = await github_api.getitem(pull_request_url)

Expand Down

0 comments on commit 25fbc55

Please sign in to comment.