Closed Fauntleroy closed 10 years ago
@pushred does that look good to you?
Nice & explicit.
Having trouble figuring out how exactly to make start
and end
actually work for redirects, so I'm going to comment out loud here. In order to have these redirects work properly, we need to check the redirect's date every time a request is made to the from
route. This is simple enough until I think about this case: Someone has a page at /cats
, but they have a temporary redirect "from": "/cats", "to": "https://www.google.com/search?q=cats"
as well. In this case the ideal behavior would be to follow the redirect while it's valid, and to go to the page when it is not. However, I'm not seeing a clear path for doing this in Express, as the redirect method is used inside of route verbs, and I don't know if there's a fallback method to go from one route handler to another one.
One idea is to merge the creation of routes between views and redirects. When a view registers its route with Express, I could check to see if any redirects exist for that route, then put a redirect middleware function in front of the view's callback.
Right now if you just put in
to
andfrom
your redirect will be permanent, and this can cause problems. Ideally unspecified redirects would be temporary, and permanent redirects would require something explicit. Here's my proposal: