mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-11 16:26:02 +00:00
fix(utils): preserve QQ image URL scheme
This commit is contained in:
1
tests/unit_tests/utils/__init__.py
Normal file
1
tests/unit_tests/utils/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
22
tests/unit_tests/utils/test_image.py
Normal file
22
tests/unit_tests/utils/test_image.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from langbot.pkg.utils.image import get_qq_image_downloadable_url
|
||||
|
||||
|
||||
def test_get_qq_image_downloadable_url_preserves_https_scheme():
|
||||
url, query = get_qq_image_downloadable_url('https://gchat.qpic.cn/gchatpic_new/abc/0?term=2&is_origin=1')
|
||||
|
||||
assert url == 'https://gchat.qpic.cn/gchatpic_new/abc/0'
|
||||
assert query == {'term': ['2'], 'is_origin': ['1']}
|
||||
|
||||
|
||||
def test_get_qq_image_downloadable_url_preserves_http_scheme():
|
||||
url, query = get_qq_image_downloadable_url('http://gchat.qpic.cn/gchatpic_new/abc/0?term=2')
|
||||
|
||||
assert url == 'http://gchat.qpic.cn/gchatpic_new/abc/0'
|
||||
assert query == {'term': ['2']}
|
||||
|
||||
|
||||
def test_get_qq_image_downloadable_url_defaults_missing_scheme_to_http():
|
||||
url, query = get_qq_image_downloadable_url('gchat.qpic.cn/gchatpic_new/abc/0?term=2')
|
||||
|
||||
assert url == 'http://gchat.qpic.cn/gchatpic_new/abc/0'
|
||||
assert query == {'term': ['2']}
|
||||
Reference in New Issue
Block a user