fix(utils): preserve QQ image URL scheme

This commit is contained in:
huanghuoguoguo
2026-05-16 10:37:12 +08:00
parent b251fc4b89
commit 93589ee381
3 changed files with 25 additions and 1 deletions

View File

@@ -0,0 +1 @@

View 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']}