-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
104 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
using System; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Jellyfin.Plugin.TeleJelly.Classes | ||
namespace Jellyfin.Plugin.TeleJelly.Classes; | ||
|
||
internal static class ControllerExtensions | ||
{ | ||
internal static class ControllerExtensions | ||
/// <summary> | ||
/// Gets the "FQDN" of the current web request context (aka. this Jellyfin server's host address). | ||
/// With respect to the configured "ForcedUrlScheme". | ||
/// </summary> | ||
/// <param name="request">Incoming Context.</param> | ||
/// <param name="configuration">of the plugin.</param> | ||
/// <returns>string of Format "FQDN.TLD".</returns> | ||
public static string GetRequestBase(this HttpRequest request, PluginConfiguration configuration) | ||
{ | ||
/// <summary> | ||
/// Gets the "FQDN" of the current web request context (aka. this Jellyfin server's host address). | ||
/// With respect to the configured "ForcedUrlScheme". | ||
/// </summary> | ||
/// <param name="request">Incoming Context.</param> | ||
/// <param name="configuration">of the plugin.</param> | ||
/// <returns>string of Format "FQDN.TLD".</returns> | ||
public static string GetRequestBase(this HttpRequest request, PluginConfiguration configuration) | ||
if (request == null) | ||
{ | ||
if (request == null) | ||
{ | ||
throw new ArgumentNullException(nameof(request), "Request is null."); | ||
} | ||
|
||
var requestPort = request.Host.Port ?? -1; | ||
var requestScheme = configuration.ForceUrlScheme ? configuration.ForcedUrlScheme : request.Scheme; | ||
throw new ArgumentNullException(nameof(request), "Request is null."); | ||
} | ||
|
||
// strip the default ports of given protocol in the final result (80 = http, 443 = https) | ||
if ((requestPort == 80 && string.Equals(requestScheme, "http", StringComparison.OrdinalIgnoreCase)) || (requestPort == 443 && string.Equals(requestScheme, "https", StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
requestPort = -1; | ||
} | ||
var requestPort = request.Host.Port ?? -1; | ||
var requestScheme = configuration.ForceUrlScheme ? configuration.ForcedUrlScheme : request.Scheme; | ||
|
||
return new UriBuilder { Scheme = requestScheme, Host = request.Host.Host, Port = requestPort, Path = request.PathBase }.ToString().TrimEnd('/'); | ||
// strip the default ports of given protocol in the final result (80 = http, 443 = https) | ||
if ((requestPort == 80 && string.Equals(requestScheme, "http", StringComparison.OrdinalIgnoreCase)) || (requestPort == 443 && string.Equals(requestScheme, "https", StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
requestPort = -1; | ||
} | ||
|
||
return new UriBuilder { Scheme = requestScheme, Host = request.Host.Host, Port = requestPort, Path = request.PathBase }.ToString().TrimEnd('/'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters