0

我正在尝试在我的 react-native 应用程序中配置 bugsnag,但我目前无法指定已编辑的密钥。以下指南提到我可以使用正则表达式:

https://docs.bugsnag.com/platforms/ios/configuration-options/#redactedkeys

但是那里的示例仅指定了字符串:

BugsnagConfiguration *config = [BugsnagConfiguration loadConfig];
config.redactedKeys = [NSSet setWithArray:@[@"password", @"credit_card_number"]];
[Bugsnag startWithConfiguration:config];

但是,我对objective-c一无所知。我有以下两个我想使用的正则表达式:

[/\w*password\w*/i, /\w*sessiontoken\w*/i]

如何将它们添加到 bugsnag 的配置中?

4

1 回答 1

0

以下是我的做法:

BugsnagConfiguration *config = [BugsnagConfiguration loadConfig];

NSRegularExpressionOptions opts = NSRegularExpressionCaseInsensitive;
NSRegularExpression *tokenRegExp = [NSRegularExpression regularExpressionWithPattern:@"\w*sessiontoken\w*" options: opts error:nil];
NSRegularExpression *passwordRegExp = [NSRegularExpression regularExpressionWithPattern:@"\w*password\w*" options: opts error:nil];

config.redactedKeys = [NSSet setWithArray:@[tokenRegExp, passwordRegExp]];
[Bugsnag startWithConfiguration:config];
于 2020-12-04T08:27:12.110 回答