From f31186d20b6e18455271e1986f48a70a4eae57d0 Mon Sep 17 00:00:00 2001 From: cadorn Date: Tue, 14 Aug 2012 14:34:59 -0700 Subject: [PATCH] regular expression support for checking routes --- lib/engine.io.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/engine.io.js b/lib/engine.io.js index 888b80700..da32a8d60 100644 --- a/lib/engine.io.js +++ b/lib/engine.io.js @@ -96,14 +96,25 @@ exports.listen = function (port, options, fn) { exports.attach = function (server, options) { var engine = new exports.Server(options) , options = options || {} - , path = (options.path || '/engine.io').replace(/\/$/, '') + , path = '/engine.io' , resource = options.resource || 'default' + if (typeof options.path === 'string') { + path = options.path.replace(/\/$/, ''); + // normalize path path += '/' + resource + '/'; + } else + if (typeof options.path === 'object' && options.path.test) { + path = options.path; + } function check (req) { + if (typeof path === 'string') { return path == req.url.substr(0, path.length); + } else { + return path.test(req.url); + } } // cache and clean up listeners