@@ -178,7 +178,7 @@ protected function getRedirectResponseBySwitchParam(Request $request): RedirectR
178
178
$ redirectUrl .= '? ' .Request::normalizeQueryString (http_build_query ($ queryParams , '' , '& ' ));
179
179
}
180
180
} else {
181
- $ redirectUrl = $ this -> getCurrentHost ( $ request );
181
+ $ redirectUrl = $ request -> getSchemeAndHttpHost ( );
182
182
}
183
183
}
184
184
@@ -188,24 +188,18 @@ protected function getRedirectResponseBySwitchParam(Request $request): RedirectR
188
188
/**
189
189
* Do we have to redirect?
190
190
*
191
- * @param string $view For which view should be check?
191
+ * @param string $viewType The view we want to redirect to
192
192
*/
193
- protected function mustRedirect (Request $ request , string $ view ): bool
193
+ protected function mustRedirect (Request $ request , string $ viewType ): bool
194
194
{
195
- if (!isset ($ this ->redirectConf [$ view ])
196
- || !$ this ->redirectConf [$ view ]['is_enabled ' ]
197
- || (self ::NO_REDIRECT === $ this ->getRoutingOption ($ request ->get ('_route ' ), $ view ))
195
+ if (!isset ($ this ->redirectConf [$ viewType ])
196
+ || !$ this ->redirectConf [$ viewType ]['is_enabled ' ]
197
+ || (self ::NO_REDIRECT === $ this ->getRoutingOption ($ request ->get ('_route ' ), $ viewType ))
198
198
) {
199
199
return false ;
200
200
}
201
201
202
- $ isHost = ($ this ->getCurrentHost ($ request ) === $ this ->redirectConf [$ view ]['host ' ]);
203
-
204
- if (!$ isHost ) {
205
- return true ;
206
- }
207
-
208
- return false ;
202
+ return $ request ->getSchemeAndHttpHost () !== $ this ->redirectConf [$ viewType ]['host ' ];
209
203
}
210
204
211
205
protected function getRoutingOption (string $ routeName , string $ optionName ): ?string
@@ -228,28 +222,23 @@ protected function getRoutingOption(string $routeName, string $optionName): ?str
228
222
return null ;
229
223
}
230
224
231
- protected function getCurrentHost (Request $ request ): string
232
- {
233
- return $ request ->getScheme ().':// ' .$ request ->getHost ();
234
- }
235
-
236
- protected function getRedirectUrl (Request $ request , string $ platform ): ?string
225
+ protected function getRedirectUrl (Request $ request , string $ view ): ?string
237
226
{
238
- if (($ routingOption = $ this ->getRoutingOption ($ request ->get ('_route ' ), $ platform ))) {
227
+ if (($ routingOption = $ this ->getRoutingOption ($ request ->get ('_route ' ), $ view ))) {
239
228
if (self ::REDIRECT === $ routingOption ) {
240
229
// Make sure to hint at the device override, otherwise infinite loop
241
230
// redirection may occur if different device views are hosted on
242
231
// different domains (since the cookie can't be shared across domains)
243
232
$ queryParams = $ request ->query ->all ();
244
- $ queryParams [$ this ->deviceView ->getSwitchParam ()] = $ platform ;
233
+ $ queryParams [$ this ->deviceView ->getSwitchParam ()] = $ view ;
245
234
246
- return rtrim ($ this ->redirectConf [$ platform ]['host ' ], '/ ' ).$ request ->getPathInfo ().'? ' .Request::normalizeQueryString (http_build_query ($ queryParams, '' , ' & ' ));
235
+ return rtrim ($ this ->redirectConf [$ view ]['host ' ], '/ ' ).$ request ->getPathInfo ().'? ' .Request::normalizeQueryString (http_build_query ($ queryParams ));
247
236
}
248
237
if (self ::REDIRECT_WITHOUT_PATH === $ routingOption ) {
249
238
// Make sure to hint at the device override, otherwise infinite loop
250
239
// redirections may occur if different device views are hosted on
251
240
// different domains (since the cookie can't be shared across domains)
252
- return $ this ->redirectConf [$ platform ]['host ' ].'? ' .$ this ->deviceView ->getSwitchParam ().'= ' .$ platform ;
241
+ return $ this ->redirectConf [$ view ]['host ' ].'? ' .$ this ->deviceView ->getSwitchParam ().'= ' .$ view ;
253
242
}
254
243
255
244
return null ;
0 commit comments