Skip to content

Commit

Permalink
Merge pull request #244 from wakatime/main
Browse files Browse the repository at this point in the history
Release v5.13.1
  • Loading branch information
alanhamlett authored Mar 26, 2024
2 parents 8146c01 + 23e7263 commit ce874a1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions WakaTime/Extensions/AXUIElementExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ extension AXUIElement {
FilterManager.filterBrowsedSites(url)
else { return nil }

// TODO: return only domain part depending on user setting
return url
guard PropertiesManager.domainPreference == .domain else { return url }

return domainFromUrl(url)
}

return title(for: monitoredApp)
Expand Down Expand Up @@ -320,6 +321,13 @@ extension AXUIElement {
return nil
}

func domainFromUrl(_ url: String) -> String? {
guard let host = URL(string: url)?.host else { return nil }
let domain = host.replacingOccurrences(of: "^www.", with: "", options: .regularExpression)
guard let port = URL(string: url)?.port else { return domain }
return "\(domain):\(port)"
}

// Traverses the element's subtree (breadth-first) until visitor() returns false or traversal is completed
func traverseDown(visitor: (AXUIElement) -> Bool) {
var queue: [AXUIElement] = [self]
Expand Down

0 comments on commit ce874a1

Please sign in to comment.