Prevent multiple vhost responses #395

Merged
merged 1 commit into from Oct 19, 2011

3 participants

@zzen

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('*(?<!static).foo.com', connect.createServer(...middleware...))
);
@melda

+1

@tj
Sencha Labs member
tj commented Oct 19, 2011

nope you're right, definitely a bug

@tj tj merged commit c388999 into senchalabs:master Oct 19, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment