Skip to content

Commit 381fed2

Browse files
author
Дмитрий Скорбовенко
committed
ISSUE-7675 Allow to use regex in process name
1 parent 476428a commit 381fed2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

mitmproxy-macos/redirector/network-extension/InterceptConf.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ enum Pattern {
2828
func matches(_ processInfo: ProcessInfo) -> Bool {
2929
switch self {
3030
case .pid(let pid):
31-
return processInfo.pid == pid
31+
processInfo.pid == pid
3232
case .process(let name):
3333
if let processName = processInfo.path {
34-
return processName.contains(name)
34+
if let regex = try? NSRegularExpression(pattern: name) {
35+
let range = NSRange(location: 0, length: processName.utf16.count)
36+
regex.firstMatch(in: processName, range: range) != nil
37+
} else {
38+
processName.contains(name)
39+
}
3540
} else {
36-
return false
41+
false
3742
}
3843
}
3944
}

0 commit comments

Comments
 (0)