Skip to content

Commit

Permalink
fix: non-www hosts not being properly picked up
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Jan 12, 2024
1 parent a0e54fb commit 3453a40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Sources/hyper-focus/action_handler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,19 @@ enum ActionHandler {
// TODO: add 'www.' to all host entries which are not regex, this is not something users want to do manually!
let blockHostsWithWWW = blockHosts.map { host in
if isRegexString(host) {
return host
return [host]
} else {
return "www.\(host)"
return ["www.\(host)", host]
}
}
}.flatMap { $0 }

let allowHostsWithWWW = allowHosts.map { host in
if isRegexString(host) {
return host
return [host]
} else {
return "www.\(host)"
return ["www.\(host)", host]
}
}
}.flatMap { $0 }

if match(host, allowHostsWithWWW) {
error("host is in allow_hosts, releasing")
Expand Down
2 changes: 2 additions & 0 deletions Tests/hyper-focusTests/action_handlerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ final class action_handlerTests: XCTestCase {

XCTAssertEqual(true, ActionHandler.match("google.com/news/something", ["/^google.*/", "google.com/news"]))
}

// TODO: test full stack browserAction
}

0 comments on commit 3453a40

Please sign in to comment.