Skip to content

Commit

Permalink
Remove forceRedirectToPath as we now have a better way to disable JS …
Browse files Browse the repository at this point in the history
…helpers per form (see form documentation). Fixes #862
  • Loading branch information
mpscholten committed May 21, 2021
1 parent 478e6de commit 9bc0395
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
13 changes: 0 additions & 13 deletions IHP/Controller/Redirect.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Copyright: (c) digitally induced GmbH, 2020
module IHP.Controller.Redirect
( redirectTo
, redirectToPath
, forceRedirectToPath
, redirectToUrl
, redirectBack
, redirectBackWithFallback
Expand Down Expand Up @@ -54,18 +53,6 @@ redirectToPath :: (?context :: ControllerContext) => Text -> IO ()
redirectToPath path = redirectToUrl (fromConfig baseUrl <> path)
{-# INLINABLE redirectToPath #-}

-- | like 'redirectToPath', but forcing full page reload
--
-- Forces reload by using a custom HTTP OK header mimicking a HTTP redirect
-- which is used as a signal to the AJAX call to perform page reload.
-- currently this is a workaround of last resort when you can't make your Javscript
-- code behave properly together with morphdom and/or turbolinks
--
-- use 'forceRedirectToPath (pathTo action)' if you want to redirect to a controller action
forceRedirectToPath :: (?context :: ControllerContext) => Text -> IO ()
forceRedirectToPath path = respondAndExit $ Wai.responseLBS (Status 280 "IHP ForceRedirect") [(hLocation, cs (fromConfig baseUrl <> path))] ""
{-# INLINABLE forceRedirectToPath #-}

-- | Redirects to a url (given as a string)
--
-- __Example:__
Expand Down
8 changes: 0 additions & 8 deletions lib/IHP/static/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,6 @@ window.submitForm = function (form, possibleClickedButton) {
);
}

// see IHP.Controller.Redirect.forceRedirectToPath for motivation
if (280 == request.status) {
// history.pushState({}, '', request.responseURL);
var newloc = request.getResponseHeader('Location');
location.assign(newloc);
return;
}

if (window.Turbolinks) {
var snapshot = new Turbolinks.Snapshot(
new Turbolinks.HeadDetails(request.response.head),
Expand Down

0 comments on commit 9bc0395

Please sign in to comment.