Skip to content

Commit

Permalink
Better urllib.parse usage
Browse files Browse the repository at this point in the history
- Use `urlsplit` instead of `urlparse` (https://rednafi.com/python/use_urlsplit_over_urlparse/)
- Use `.hostname` instead of manually parsing `.netloc`
  • Loading branch information
injust committed Mar 7, 2025
1 parent 879f5fa commit e009fa9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tgtg_scanner/tgtg/tgtg_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from datetime import datetime
from http import HTTPStatus
from typing import List, Union
from urllib.parse import urljoin, urlparse
from urllib.parse import urljoin, urlsplit

import requests
from requests.adapters import HTTPAdapter
Expand Down Expand Up @@ -85,7 +85,7 @@ def __init__(
if proxies:
self.proxies = proxies
if datadome_cookie:
domain = urlparse(base_url).netloc.split(":")[0]
domain = urlsplit(base_url).hostname
domain = f".{'local' if domain == 'localhost' else domain}"
self.cookies.set("datadome", datadome_cookie, domain=domain, path="/", secure=True)

Expand Down

0 comments on commit e009fa9

Please sign in to comment.