From 54ba65ba1fbfcb42a11ebc2058675a4049f31838 Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Tue, 31 Dec 2013 15:33:43 -0500 Subject: [PATCH] bump length of subdomain to 10 --- lib/rand_id.js | 7 ++++--- server.js | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/rand_id.js b/lib/rand_id.js index 25f4815..d0b1c13 100644 --- a/lib/rand_id.js +++ b/lib/rand_id.js @@ -1,12 +1,13 @@ +// all url safe +// can't use uppercase because hostnames are lowercased +var chars = 'abcdefghijklmnopqrstuvwxyz'; -var chars = 'abcdefghiklmnopqrstuvwxyz'; module.exports = function rand_id() { var randomstring = ''; - for (var i=0; i<4; ++i) { + for (var i=0; i<10; ++i) { var rnum = Math.floor(Math.random() * chars.length); randomstring += chars[rnum]; } return randomstring; } - diff --git a/server.js b/server.js index 17bc3b1..673bc53 100644 --- a/server.js +++ b/server.js @@ -32,7 +32,7 @@ function maybe_bounce(req, res, bounce) { return false; } - var match = hostname.match(/^([a-z]{4})[.].*/); + var match = hostname.match(/^([a-z0-9]{4,10})[.].*/); // not for a specific client // pass on to regular server @@ -180,7 +180,7 @@ module.exports = function(opt) { app.get('/:req_id', function(req, res, next) { var req_id = req.param('req_id'); - if (! /[a-z]{4}/.test(req_id)) { + if (! /[A-Za-z0-9]{4,10}/.test(req_id)) { return next(); }