Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

0.2.3

latest commit ba83539226
Raynos (Jake Verbaten) authored
Failed to load latest commit information.
test add redirect(req, res, 'back') feature
.gitignore first
.travis.yml first
LICENCE first
Makefile first
README.md add redirect(req, res, 'back') feature
index.js add redirect(req, res, 'back') feature
package.json 0.2.3

README.md

redirecter build status

Easy redirection

Example

var redirect = require("redirecter")
var http = require("http")

http.createServer(function handleRequest(req, res) {
    if (req.url === "/redir") {
        redirect(req, res, "/foo")
    } else if (req.url.match(/^\/status/)) {
        var status = parseInt(req.url.substr(7), 10)
        redirect(req, res, {
            target: "/foo"
            , statusCode: status
        })
    } else if (req.url === "/back") {
        // shorthand for redirecter(req, res, req.getHeader("Referrer"))
        redirecter(req, res, "back")
    } else {
        res.end("foo")
    }
}).listen(8080)

Installation

npm install redirecter

Tests

make test

Contributors

  • Raynos

MIT Licenced

Something went wrong with that request. Please try again.