Skip to content

Commit 70c626c

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

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ enum Pattern {
3131
return 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+
return regex.firstMatch(in: processName, range: range) != nil
37+
} else {
38+
return processName.contains(name)
39+
}
3540
} else {
36-
return false
41+
return false
3742
}
3843
}
3944
}

0 commit comments

Comments
 (0)