Skip to content

Commit 10b68a7

Browse files
committed
stick with one comparison method
1 parent 05dab59 commit 10b68a7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Bugsnag/Configuration.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ public class Configuration : IConfiguration
1515
public const string DefaultSessionEndpoint = "https://sessions.bugsnag.com";
1616
public const string HubEndpoint = "https://notify.insighthub.smartbear.com";
1717
public const string HubSessionEndpoint = "https://sessions.insighthub.smartbear.com";
18-
private static readonly Regex HubKeyRegex = new Regex(
19-
@"^0{5}[0-9a-fA-F]{27}$",
20-
RegexOptions.Compiled);
18+
private const string HubKeyPrefix = "00000";
19+
2120

2221
public Configuration() : this(string.Empty)
2322
{
@@ -28,8 +27,7 @@ public Configuration(string apiKey)
2827
{
2928
ApiKey = apiKey;
3029

31-
// Choose the correct hosts first-time-round
32-
bool isHubKey = IsHubApiKey(apiKey);
30+
bool isHubKey = IsHubKey(apiKey);
3331
Endpoint = new Uri(isHubKey ? HubEndpoint : DefaultEndpoint);
3432
SessionEndpoint = new Uri(isHubKey ? HubSessionEndpoint : DefaultSessionEndpoint);
3533

@@ -74,7 +72,8 @@ public Configuration(string apiKey)
7472

7573
public int MaximumBreadcrumbs { get; set; }
7674

77-
private static bool IsHubApiKey(string key) =>
78-
!string.IsNullOrWhiteSpace(key) && HubKeyRegex.IsMatch(key);
75+
private static bool IsHubKey(string key) =>
76+
!string.IsNullOrEmpty(key) &&
77+
key.StartsWith(HubKeyPrefix, StringComparison.OrdinalIgnoreCase);
7978
}
8079
}

0 commit comments

Comments
 (0)