Skip to content

Commit ea0c49b

Browse files
committed
Move MethodAndUrlUtils to GraphUtils unit
1 parent 826d644 commit ea0c49b

File tree

4 files changed

+17
-24
lines changed

4 files changed

+17
-24
lines changed

DevProxy.Plugins/Reporting/GraphMinimalPermissionsGuidancePlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public override async Task AfterRecordingStopAsync(RecordingArgs e, Cancellation
9393
}
9494

9595
var methodAndUrlString = request.Message;
96-
var methodAndUrl = MethodAndUrlUtils.ToMethodAndUrl(methodAndUrlString);
96+
var methodAndUrl = GraphUtils.GetMethodAndUrl(methodAndUrlString);
9797
if (methodAndUrl.Method.Equals("OPTIONS", StringComparison.OrdinalIgnoreCase))
9898
{
9999
continue;

DevProxy.Plugins/Reporting/GraphMinimalPermissionsPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public override async Task AfterRecordingStopAsync(RecordingArgs e, Cancellation
7070
}
7171

7272
var methodAndUrlString = request.Message;
73-
var methodAndUrl = MethodAndUrlUtils.ToMethodAndUrl(methodAndUrlString);
73+
var methodAndUrl = GraphUtils.GetMethodAndUrl(methodAndUrlString);
7474
if (methodAndUrl.Method.Equals("OPTIONS", StringComparison.OrdinalIgnoreCase))
7575
{
7676
continue;

DevProxy.Plugins/Utils/GraphUtils.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace DevProxy.Plugins.Utils;
1111

12+
internal readonly record struct MethodAndUrl(string Method, string Url);
13+
1214
sealed class GraphUtils(
1315
HttpClient httpClient,
1416
ILogger<GraphUtils> logger)
@@ -96,4 +98,17 @@ internal async Task<IEnumerable<string>> UpdateUserScopesAsync(IEnumerable<strin
9698

9799
return newMinimalScopes;
98100
}
101+
102+
public static MethodAndUrl GetMethodAndUrl(string methodAndUrlString)
103+
{
104+
ArgumentException.ThrowIfNullOrWhiteSpace(methodAndUrlString, nameof(methodAndUrlString));
105+
106+
var info = methodAndUrlString.Split(" ");
107+
if (info.Length > 2)
108+
{
109+
info = [info[0], string.Join(" ", info.Skip(1))];
110+
}
111+
return new(Method: info[0], Url: info[1]);
112+
}
113+
99114
}

DevProxy.Plugins/Utils/MethodAndUrlUtils.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)