Create appropriate parser based on content type and URL.
(content_type: str = '', url: str | None = None)
| 209 | |
| 210 | |
| 211 | def _get_parser(content_type: str = '', url: str | None = None) -> _XmlSitemapParser | _TxtSitemapParser: |
| 212 | """Create appropriate parser based on content type and URL.""" |
| 213 | if 'text/plain' in content_type.lower() or (url and URL(url).path.endswith('.txt')): |
| 214 | return _TxtSitemapParser() |
| 215 | # Default to XML parser for most cases |
| 216 | return _XmlSitemapParser() |
| 217 | |
| 218 | |
| 219 | def _get_origin_url(source: SitemapSource) -> str: |
no test coverage detected