Skip to content

Commit e0af487

Browse files
committed
Use Util for detecting WASM
1 parent 348d79b commit e0af487

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/SignalR/clients/csharp/Http.Connections.Client/src/Internal/Utils.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5+
using System.Runtime.InteropServices;
56

67
namespace Microsoft.AspNetCore.Http.Connections.Client.Internal
78
{
@@ -41,5 +42,10 @@ internal static Uri AppendQueryString(Uri url, string qs)
4142
builder.Query = newQueryString;
4243
return builder.Uri;
4344
}
45+
46+
internal static bool IsRunningBlazorWasm()
47+
{
48+
return RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY"));
49+
}
4450
}
4551
}

src/SignalR/clients/csharp/Http.Connections.Client/src/Internal/WebSocketsTransport.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,14 @@ public async Task StartAsync(Uri url, TransferFormat transferFormat, Cancellatio
108108

109109
var resolvedUrl = ResolveWebSocketsUrl(url);
110110

111-
var isWasm = RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY"));
112-
113111
// We don't need to capture to a local because we never change this delegate.
114112
if (_accessTokenProvider != null)
115113
{
116114
var accessToken = await _accessTokenProvider();
117115
if (!string.IsNullOrEmpty(accessToken))
118116
{
119117
// We can't use request headers in the browser, so instead append the token as a query string if running WASM
120-
if (isWasm)
118+
if (Utils.IsRunningBlazorWasm())
121119
{
122120
var accessTokenEncoded = UrlEncoder.Default.Encode(accessToken);
123121
accessTokenEncoded = "access_token=" + accessTokenEncoded;

0 commit comments

Comments
 (0)