@@ -546,9 +546,7 @@ def _check_uri(self, uri: str, hyperlink: Hyperlink) -> _URIProperties:
546546 ) as response :
547547 if anchor and self .check_anchors and response .ok :
548548 try :
549- found = contains_anchor (
550- response , anchor , ignore_case = self .ignore_case
551- )
549+ found = contains_anchor (response , anchor )
552550 except UnicodeDecodeError :
553551 return (
554552 _Status .IGNORED ,
@@ -706,11 +704,9 @@ def _get_request_headers(
706704 return {}
707705
708706
709- def contains_anchor (
710- response : Response , anchor : str , * , ignore_case : bool = False
711- ) -> bool :
707+ def contains_anchor (response : Response , anchor : str ) -> bool :
712708 """Determine if an anchor is contained within an HTTP response."""
713- parser = AnchorCheckParser (anchor , ignore_case = ignore_case )
709+ parser = AnchorCheckParser (anchor )
714710 # Read file in chunks. If we find a matching anchor, we break
715711 # the loop early in hopes not to have to download the whole thing.
716712 for chunk in response .iter_content (chunk_size = 4096 , decode_unicode = True ):
@@ -728,24 +724,17 @@ def contains_anchor(
728724class AnchorCheckParser (HTMLParser ):
729725 """Specialised HTML parser that looks for a specific anchor."""
730726
731- def __init__ (self , search_anchor : str , * , ignore_case : bool = False ) -> None :
727+ def __init__ (self , search_anchor : str ) -> None :
732728 super ().__init__ ()
733729
734730 self .search_anchor = search_anchor
735- self .ignore_case = ignore_case
736731 self .found = False
737732
738733 def handle_starttag (self , tag : Any , attrs : Any ) -> None :
739734 for key , value in attrs :
740- if key in {'id' , 'name' }:
741- if self .ignore_case :
742- match = value .lower () == self .search_anchor .lower ()
743- else :
744- match = value == self .search_anchor
745- if match :
746- self .found = True
747- break
748-
735+ if key in {'id' , 'name' } and value == self .search_anchor :
736+ self .found = True
737+ break
749738
750739def _allowed_redirect (
751740 url : str , new_url : str , allowed_redirects : dict [re .Pattern [str ], re .Pattern [str ]]
0 commit comments