Skip to content

Exclude "data:" URLs from "assert_no_404_errors()" #856

@mdmintz

Description

@mdmintz

Exclude data: URLs from the assert_no_404_errors() scan.

That can lead to false-positives. Currently, javascript: and mailto: URLs are already excluded.

The status code for each link is currently obtained by calling:

def _get_link_status_code(link, allow_redirects=False, timeout=5):
    """ Get the status code of a link.
        If the timeout is exceeded, will return a 404.
        For a list of available status codes, see:
        https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
    """
    status_code = None
    try:
        response = requests.get(
            link, allow_redirects=allow_redirects, timeout=timeout)
        status_code = response.status_code
    except Exception:
        status_code = 404
    return status_code

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions