@@ -26,6 +26,7 @@ public class ConfigurationService : IGalleryConfigurationService, IConfiguration
2626
2727 private readonly Lazy < string > _httpSiteRootThunk ;
2828 private readonly Lazy < string > _httpsSiteRootThunk ;
29+ private readonly Lazy < string > _httpsEmailSupportSiteRootThunk ;
2930 private readonly Lazy < IAppConfiguration > _lazyAppConfiguration ;
3031 private readonly Lazy < FeatureConfiguration > _lazyFeatureConfiguration ;
3132 private readonly Lazy < IServiceBusConfiguration > _lazyServiceBusConfiguration ;
@@ -59,6 +60,7 @@ public ConfigurationService()
5960 {
6061 _httpSiteRootThunk = new Lazy < string > ( GetHttpSiteRoot ) ;
6162 _httpsSiteRootThunk = new Lazy < string > ( GetHttpsSiteRoot ) ;
63+ _httpsEmailSupportSiteRootThunk = new Lazy < string > ( GetHttpsSupportEmailSiteRoot ) ;
6264
6365 _lazyAppConfiguration = new Lazy < IAppConfiguration > ( ( ) => ResolveSettings ( ) . Result ) ;
6466 _lazyFeatureConfiguration = new Lazy < FeatureConfiguration > ( ( ) => ResolveFeatures ( ) . Result ) ;
@@ -89,6 +91,15 @@ public string GetSiteRoot(bool useHttps)
8991 return useHttps ? _httpsSiteRootThunk . Value : _httpSiteRootThunk . Value ;
9092 }
9193
94+ /// <summary>
95+ /// Gets the support email site root using the specified protocol
96+ /// </summary>
97+ /// <returns></returns>
98+ public string GetSupportEmailSiteRoot ( )
99+ {
100+ return _httpsEmailSupportSiteRootThunk . Value ;
101+ }
102+
92103 public Task < T > Get < T > ( ) where T : NuGet . Services . Configuration . Configuration , new ( )
93104 {
94105 // Get the prefix specified by the ConfigurationKeyPrefixAttribute on the class if it exists.
@@ -209,19 +220,7 @@ private string GetHttpSiteRoot()
209220 {
210221 var siteRoot = Current . SiteRoot ;
211222
212- if ( siteRoot == null )
213- {
214- // No SiteRoot configured in settings.
215- // Fallback to detected site root.
216- var request = GetCurrentRequest ( ) ;
217- siteRoot = request . Url . GetLeftPart ( UriPartial . Authority ) + '/' ;
218- }
219-
220- if ( ! siteRoot . StartsWith ( "http://" , StringComparison . OrdinalIgnoreCase )
221- && ! siteRoot . StartsWith ( "https://" , StringComparison . OrdinalIgnoreCase ) )
222- {
223- throw new InvalidOperationException ( "The configured site root must start with either http:// or https://." ) ;
224- }
223+ CheckValidSiteRoot ( siteRoot ) ;
225224
226225 if ( siteRoot . StartsWith ( "https://" , StringComparison . OrdinalIgnoreCase ) )
227226 {
@@ -242,5 +241,36 @@ private string GetHttpsSiteRoot()
242241
243242 return "https://" + siteRoot . Substring ( 7 ) ;
244243 }
244+
245+ private string GetHttpsSupportEmailSiteRoot ( )
246+ {
247+ var siteRoot = Current . SupportEmailSiteRoot ;
248+
249+ CheckValidSiteRoot ( siteRoot ) ;
250+
251+ if ( siteRoot . StartsWith ( "http://" , StringComparison . OrdinalIgnoreCase ) )
252+ {
253+ siteRoot = "https://" + siteRoot . Substring ( 7 ) ;
254+ }
255+
256+ return siteRoot ;
257+ }
258+
259+ private void CheckValidSiteRoot ( string siteRoot )
260+ {
261+ if ( siteRoot == null )
262+ {
263+ // No SiteRoot configured in settings.
264+ // Fallback to detected site root.
265+ var request = GetCurrentRequest ( ) ;
266+ siteRoot = request . Url . GetLeftPart ( UriPartial . Authority ) + '/' ;
267+ }
268+
269+ if ( ! siteRoot . StartsWith ( "http://" , StringComparison . OrdinalIgnoreCase )
270+ && ! siteRoot . StartsWith ( "https://" , StringComparison . OrdinalIgnoreCase ) )
271+ {
272+ throw new InvalidOperationException ( "The configured site root must start with either http:// or https://." ) ;
273+ }
274+ }
245275 }
246276}
0 commit comments