snapshot of https://github.com/ActivityWatch/aw-core.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Build / Test on ubuntu-latest, py-3.8 (push) Successful in 4m21s
Lint / lint (push) Successful in 25s
Build / Test on macOS-latest, py-3.8 (push) Has been cancelled
Build / Test on windows-latest, py-3.8 (push) Has been cancelled
CodeQL / Analyze (python) (push) Failing after 1s
Some checks failed
Build / Test on ubuntu-latest, py-3.8 (push) Successful in 4m21s
Lint / lint (push) Successful in 25s
Build / Test on macOS-latest, py-3.8 (push) Has been cancelled
Build / Test on windows-latest, py-3.8 (push) Has been cancelled
CodeQL / Analyze (python) (push) Failing after 1s
This commit is contained in:
32
aw_transform/split_url_events.py
Normal file
32
aw_transform/split_url_events.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import logging
|
||||
from typing import List
|
||||
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from aw_core.models import Event
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def split_url_events(events: List[Event]) -> List[Event]:
|
||||
for event in events:
|
||||
if "url" in event.data:
|
||||
url = event.data["url"]
|
||||
parsed_url = urlparse(url)
|
||||
event.data["$protocol"] = parsed_url.scheme
|
||||
netloc = parsed_url.netloc
|
||||
if netloc:
|
||||
domain = netloc[4:] if netloc[:4] == "www." else netloc
|
||||
elif parsed_url.scheme:
|
||||
# For URLs without a domain (e.g. file://, about:),
|
||||
# use the scheme as domain so they don't all cluster as empty.
|
||||
domain = parsed_url.scheme
|
||||
else:
|
||||
domain = ""
|
||||
event.data["$domain"] = domain
|
||||
event.data["$path"] = parsed_url.path
|
||||
event.data["$params"] = parsed_url.params
|
||||
event.data["$options"] = parsed_url.query
|
||||
event.data["$identifier"] = parsed_url.fragment
|
||||
# TODO: Parse user, port etc aswell
|
||||
return events
|
||||
Reference in New Issue
Block a user