Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix browser filter strings #237

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WakaTime/Helpers/FilterManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class FilterManager {
switch PropertiesManager.filterType {
case .denylist:
for pattern in patterns {
if httpAddress.matchesRegex(pattern) || httpsAddress.matchesRegex(pattern) {
if address.matchesRegex(pattern) || httpAddress.matchesRegex(pattern) || httpsAddress.matchesRegex(pattern) {
// Address matches a pattern on the denylist. Filter the site out.
return false
}
}
case .allowlist:
let addressMatchesAllowlist = patterns.contains { pattern in
httpAddress.matchesRegex(pattern) || httpsAddress.matchesRegex(pattern)
address.matchesRegex(pattern) || httpAddress.matchesRegex(pattern) || httpsAddress.matchesRegex(pattern)
}
// If none of the patterns on the allowlist match the given address, filter the site out
if !addressMatchesAllowlist {
Expand Down
14 changes: 8 additions & 6 deletions WakaTime/Helpers/PropertiesManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ class PropertiesManager {
get {
guard let allowlist = UserDefaults.standard.string(forKey: Keys.allowlist.rawValue) else {
return
"https://github.com/\n" +
"https://gitlab.com/\n" +
"https://stackoverflow.com/\n" +
"https://docs.python.org/\n" +
"https://google.com/\n" +
"https://npmjs.com"
"https?://(\\w\\.)*github\\.com/\n" +
"https?://(\\w\\.)*gitlab\\.com/\n" +
"^stackoverflow\\.com/\n" +
"^docs\\.python\\.org/\n" +
"https?://(\\w\\.)*golang\\.org/\n" +
"https?://(\\w\\.)*go\\.dev/\n" +
"https?://(\\w\\.)*npmjs\\.com/\n" +
"https?//localhost[:\\d+]?/"
}

return allowlist
Expand Down
6 changes: 3 additions & 3 deletions WakaTime/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SettingsView: NSView, NSTextFieldDelegate, NSTextViewDelegate {
// MARK: Denylist/Allowlist

lazy var filterTypeLabel: NSTextField = {
NSTextField(labelWithString: "Logging Style:")
NSTextField(labelWithString: "Browser Filter:")
}()

lazy var filterSegmentedControl: NSSegmentedControl = {
Expand Down Expand Up @@ -230,11 +230,11 @@ class SettingsView: NSView, NSTextFieldDelegate, NSTextViewDelegate {
let denylistTitle = "Denylist:"
let denylistRemarks =
"Sites that you don't want to show in your reports. " +
"One line per site."
"Only applicable to browsing activity. One regex per line."
let allowlistTitle = "Allowlist:"
let allowlistRemarks =
"Sites that you want to show in your reports. " +
"One line per site."
"Only applicable to browsing activity. One regex per line."

var title: String
var remarks: String
Expand Down
Loading