Skip to content

Commit

Permalink
Merge pull request l3tnun#12 from rokoucha/fix/base64_encode
Browse files Browse the repository at this point in the history
fix: base64 エンコーディング時のエラーを修正
  • Loading branch information
l3tnun authored Jul 31, 2021
2 parents c83bf07 + 1898fc4 commit 2037af3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion urlutil.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import base64
import re

# urllib2.Request で開く url と headers を生成する
Expand All @@ -14,7 +15,7 @@ def getUrlInfo(server_url):
if match is not None:
# BASIC 認証
result["url"] = match.group(1) + "://" + match.group(4);
result["headers"]["authorization"] = "Basic " + (match.group(2) + ":" + match.group(3)).encode("base64")[:-1]
result["headers"]["authorization"] = "Basic " + base64.b64encode((match.group(2) + ":" + match.group(3)).encode()).decode();
else:
match = re.search(r"^(http|https)://(.+)", server_url)
result["url"] = match.group(1) + "://" + match.group(2);
Expand Down

0 comments on commit 2037af3

Please sign in to comment.