Skip to content

Commit

Permalink
Merge pull request socketio#744 from ajaxorg/regexp-as-resource
Browse files Browse the repository at this point in the history
make it possible to use a regexp to match the socket.io resource URL
  • Loading branch information
rauchg committed Feb 9, 2012
2 parents b662704 + 09b130f commit 8c1c7a2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,17 @@ var regexp = /^\/([^\/]+)\/?([^\/]+)?\/?([^\/]+)?\/?$/
Manager.prototype.checkRequest = function (req) {
var resource = this.get('resource');

if (req.url.substr(0, resource.length) == resource) {
var uri = url.parse(req.url.substr(resource.length), true)
var match;
if (typeof resource === 'string') {
match = req.url.substr(0, resource.length);
if (match !== resource) match = null;
} else {
match = resource.exec(req.url);
if (match) match = match[0];
}

if (match) {
var uri = url.parse(req.url.substr(match.length), true)
, path = uri.pathname || ''
, pieces = path.match(regexp);

Expand Down

0 comments on commit 8c1c7a2

Please sign in to comment.