Permalink
Browse files

use 301 redirect (this is permanent)

  • Loading branch information...
coolaj86 committed Dec 14, 2012
1 parent 8e6b865 commit 6c53219f83719bf7c45f023d832d4e08cb26d088
Showing with 5 additions and 5 deletions.
  1. +4 −4 connect-nowww/index.js
  2. +1 −1 connect-nowww/package.json
View
@@ -1,20 +1,20 @@
+/*jshint strict:true node:true es5:true onevar:true laxcomma:true laxbreak:true eqeqeq:true immed:true latedef:true undef:true unused:true*/
(function () {
"use strict";
function nowww(req, res, next) {
- var match
- , host = (req.headers.host||'').replace(/^www\./, '')
+ var host = (req.headers.host||'').replace(/^www\./, '')
, hostname = host.split(':')[0]
, protocol = 'http' + (req.connection.encrypted ? 's' : '') + '://'
, href = protocol + host + req.url
- , url
;
if (host === req.headers.host) {
return next();
}
- res.statusCode = 302;
+ // Permanent Redirect
+ res.statusCode = 301;
res.setHeader('Location', href);
// TODO set token (cookie, header, something) to notify browser to notify user about www
res.write(
@@ -12,5 +12,5 @@
, "dependencies": {
}
, "main": "index"
- , "version": "1.1.1"
+ , "version": "1.1.2"
}

0 comments on commit 6c53219

Please sign in to comment.