senchalabs/connect — pull request #395 by zzen (2011-10-19 10:59:12+00:00)
Title: Prevent multiple vhost responses

Currently, vhost evaluates all matching subdomains and and executes ALL requests to vhost servers. This causes multiple responses to be served. Example:

connect(
connect.vhost('static.foo.com', connect.createServer(...middleware...)),
connect.vhost('*.foo.com', connect.createServer(...middleware...))
);

A call to `static.foo.com` causes both servers to be invoked. Is this by design? Is there any real-world use-case for this? It seems **much** more intuitive to call just the first server (ie. depend on ordering when multiple matching declarations are found).

If this change is rejected, the only other way how to accomplish the above is via unwieldy regexp like following, and that seems just wrong:

connect(
connect.vhost('static.foo.com', connect.createServer(...middleware...)),
connect.vhost('*(?