@@ -13,43 +13,29 @@ public class CookieExpirationService : ICookieExpirationService
1313 private static readonly DateTime CookieExpirationTime = new DateTime ( 2010 , 1 , 1 ) ;
1414
1515 // Google Analytics cookies
16- private static readonly IReadOnlyList < string > GoogleAnalyticsCookies = new [ ]
16+ private static readonly string [ ] GoogleAnalyticsCookies = new [ ]
1717 {
1818 "_ga" ,
1919 "_gid" ,
2020 "_gat" ,
2121 } ;
2222
2323 // Application Insights cookies
24- private static readonly IReadOnlyList < string > ApplicationInsightsCookies = new [ ]
24+ private static readonly string [ ] ApplicationInsightsCookies = new [ ]
2525 {
2626 "ai_user" ,
2727 "ai_session" ,
2828 } ;
2929
30- private readonly string _domain ;
31- private readonly string _rootDomain ;
32-
33- public CookieExpirationService ( string domain )
34- {
35- if ( string . IsNullOrEmpty ( domain ) )
36- {
37- throw new ArgumentException ( CoreStrings . ArgumentCannotBeNullOrEmpty , nameof ( domain ) ) ;
38- }
39-
40- _domain = domain ;
41- _rootDomain = GetRootDomain ( _domain ) ;
42- }
43-
4430 public void ExpireAnalyticsCookies ( HttpContextBase httpContext )
4531 {
4632 if ( httpContext == null )
4733 {
4834 throw new ArgumentNullException ( nameof ( httpContext ) ) ;
4935 }
5036
51- GoogleAnalyticsCookies . ToList ( ) . ForEach ( cookieName => ExpireCookieByName ( httpContext , cookieName , _rootDomain ) ) ;
52- ApplicationInsightsCookies . ToList ( ) . ForEach ( cookieName => ExpireCookieByName ( httpContext , cookieName ) ) ;
37+ Array . ForEach ( GoogleAnalyticsCookies , cookieName => ExpireCookieByName ( httpContext , cookieName ) ) ;
38+ Array . ForEach ( ApplicationInsightsCookies , cookieName => ExpireCookieByName ( httpContext , cookieName ) ) ;
5339 }
5440
5541 public void ExpireSocialMediaCookies ( HttpContextBase httpContext ) { }
@@ -84,22 +70,5 @@ public void ExpireCookieByName(HttpContextBase httpContext, string cookieName, s
8470 }
8571 }
8672 }
87-
88- private string GetRootDomain ( string domain )
89- {
90- var index1 = domain . LastIndexOf ( '.' ) ;
91- if ( index1 < 0 )
92- {
93- return domain ;
94- }
95-
96- var index2 = domain . LastIndexOf ( '.' , index1 - 1 ) ;
97- if ( index2 < 0 )
98- {
99- return domain ;
100- }
101-
102- return domain . Substring ( index2 + 1 ) ;
103- }
10473 }
10574}
0 commit comments