mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 00:40:56 -05:00
Set up a 301 Redirect for account/profile instead of a backbone redirect
This commit is contained in:
parent
8e82702348
commit
9db84befa6
2 changed files with 12 additions and 0 deletions
|
@ -19,6 +19,9 @@ module.exports = class CocoRouter extends Backbone.Router
|
|||
# user views
|
||||
'user/:nameOrID(/:subview)': 'userView'
|
||||
|
||||
# account views
|
||||
'account(/:subview)(/*rest)': 'accountView'
|
||||
|
||||
# Direct links
|
||||
'test/*subpath': go('TestView')
|
||||
'demo/*subpath': go('DemoView')
|
||||
|
@ -58,6 +61,9 @@ module.exports = class CocoRouter extends Backbone.Router
|
|||
view.render()
|
||||
@openView if view then view else @notFoundView()
|
||||
|
||||
accountView: (nameOrID, subview) ->
|
||||
|
||||
|
||||
cache: {}
|
||||
openRoute: (route) ->
|
||||
route = route.split('?')[0]
|
||||
|
|
|
@ -70,11 +70,17 @@ setupMiddlewareToSendOldBrowserWarningWhenPlayersViewLevelDirectly = (app) ->
|
|||
return next() if req.query['try-old-browser-anyway'] or not isOldBrowser req
|
||||
res.sendfile(path.join(__dirname, 'public', 'index_old_browser.html'))
|
||||
|
||||
setupRedirectMiddleware = (app) ->
|
||||
app.all '/account/profile/*', (req, res, next) ->
|
||||
nameOrID = req.path.split('/')[3]
|
||||
res.redirect 301, "/user/#{nameOrID}/profile"
|
||||
|
||||
exports.setupMiddleware = (app) ->
|
||||
setupMiddlewareToSendOldBrowserWarningWhenPlayersViewLevelDirectly app
|
||||
setupExpressMiddleware app
|
||||
setupPassportMiddleware app
|
||||
setupOneSecondDelayMiddleware app
|
||||
setupRedirectMiddleware app
|
||||
|
||||
###Routing function implementations###
|
||||
|
||||
|
|
Loading…
Reference in a new issue