@@ -33,7 +33,9 @@ public IActionResult AddEmployer(long organisationId, string returnUrl)
3333 comparisonBasketService . AddToBasket ( organisationId ) ;
3434 comparisonBasketService . SaveComparedEmployersToCookie ( ) ;
3535
36- return LocalRedirect ( returnUrl ) ;
36+ return Url . IsLocalUrl ( returnUrl )
37+ ? LocalRedirect ( returnUrl )
38+ : RedirectToAction ( "CompareEmployersNoYear" , "CompareEmployers" ) ;
3739 }
3840
3941 [ HttpGet ( "/compare-employers/add-js/{organisationId}" ) ]
@@ -59,7 +61,14 @@ public IActionResult RemoveEmployer(long organisationId, string returnUrl)
5961 comparisonBasketService . RemoveFromBasket ( organisationId ) ;
6062 comparisonBasketService . SaveComparedEmployersToCookie ( ) ;
6163
62- return LocalRedirect ( returnUrl ) ;
64+ if ( Url . IsLocalUrl ( returnUrl ) )
65+ {
66+ return LocalRedirect ( returnUrl ) ;
67+ }
68+
69+ return comparisonBasketService . ComparedEmployers . Any ( )
70+ ? RedirectToAction ( "CompareEmployersNoYear" , "CompareEmployers" )
71+ : RedirectToAction ( "SearchPage" , "Search" ) ;
6372 }
6473
6574 [ HttpGet ( "/compare-employers/remove-js/{organisationId}" ) ]
@@ -82,7 +91,14 @@ public IActionResult ClearEmployers(string returnUrl)
8291 comparisonBasketService . ClearBasket ( ) ;
8392 comparisonBasketService . SaveComparedEmployersToCookie ( ) ;
8493
85- return LocalRedirect ( returnUrl ) ;
94+ if ( Url . IsLocalUrl ( returnUrl ) )
95+ {
96+ return LocalRedirect ( returnUrl ) ;
97+ }
98+
99+ return comparisonBasketService . ComparedEmployers . Any ( )
100+ ? RedirectToAction ( "CompareEmployersNoYear" , "CompareEmployers" )
101+ : RedirectToAction ( "SearchPage" , "Search" ) ;
86102 }
87103
88104 [ HttpGet ( "/compare-employers" ) ]
0 commit comments