浏览代码

Fix false negative http code 404 in verification

Some links when they were being checked returned the http code 404,
but the links were working correctly.

This was happening because before the request the link was concatenated
with the / character at the end, making it a different link from the
original. If the original link didn't have a path that is
accessed by / at the end, it would return a 404 error.

This behavior made it a false negative.
pull/3049/head
Matheus Felipe 2 年前
父节点
当前提交
c2bdd9e5fc
找不到此签名对应的密钥 GPG 密钥 ID: AA785C523274872F
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. +3
    -2
      scripts/validate/links.py

+ 3
- 2
scripts/validate/links.py 查看文件

@@ -17,7 +17,7 @@ def find_links_in_text(text: str) -> List[str]:
raw_links = re.findall(link_pattern, text)

links = [
str(raw_link[0]).rstrip('/') for raw_link in raw_links
str(raw_link[0]) for raw_link in raw_links
]

return links
@@ -49,6 +49,7 @@ def check_duplicate_links(links: List[str]) -> Tuple[bool, List]:
has_duplicate = False

for link in links:
link = link.rstrip('/')
if link not in seen:
seen[link] = 1
else:
@@ -163,7 +164,7 @@ def check_if_link_is_working(link: str) -> Tuple[bool, str]:
error_message = ''

try:
resp = requests.get(link + '/', timeout=25, headers={
resp = requests.get(link, timeout=25, headers={
'User-Agent': fake_user_agent(),
'host': get_host_from_link(link)
})


正在加载...
取消
保存