fix: only the path is returned when redirect location is a path
This commit is contained in:
parent
535960b8ae
commit
8278ec5893
1 changed files with 6 additions and 1 deletions
|
@ -52,7 +52,12 @@ async def extend_short_urls(url):
|
|||
if not url:
|
||||
return url
|
||||
if r.status in [301, 302, 304, 307, 308] and 'Location' in r.headers:
|
||||
return r.headers['Location']
|
||||
if 'http' in r.headers['Location']:
|
||||
return r.headers['Location']
|
||||
else:
|
||||
# 如果 Location 头部没有 http 前缀,可能是相对路径
|
||||
# 需要将其转换正确的链接
|
||||
return urlparse(url)._replace(path=r.headers['Location']).geturl()
|
||||
return url
|
||||
|
||||
def extract_tb_url_from_html(html_content):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue