Skip to content
Snippets Groups Projects
Select Git revision
  • feadc1fb6d349fe497092e2e75b8b1fab2a52e69
  • master default protected
2 results

env.R

Blame
  • Forked from SERG / woRkflow
    Source project has a limited visibility.
    autoredirect.ts 615 B
    import * as express from "express"
    import {debug} from "./debug";
    
    
    function AutoRedirect(req : express.Request, res : express.Response, next : express.NextFunction){
    
        //get last character of req string.
        let lastchar : string = req.path.substr(req.path.length-1, 1);
        debug(`Last character: '${lastchar}' : ${req.path}`);
    
        if(lastchar == '/'){
            res.redirect(req.path + "index.html");
            res.end();
        // }else if(req.path.lastIndexOf('.') < req.path.lastIndexOf('/')){
        //     res.redirect(req.path + ".html");
        //     res.end();
        }else
            next();
    }
    
    export {AutoRedirect};