kalasjocke/sinatra-asset-pipeline — pull request #23 by lepfhty (2013-10-31 08:21:38+00:00)
Title: delegate asset urls to the sprockets server in development and test

When an asset has both `require` directives and body content, and it is retrieved via the url `/assets/?body=1`, only the body should be returned without the concatenated content of the `require`d files.

This bug is revealed when using the `javascript_tag` helper with `:expand => true`. For example, if app.js contains:
```javascript
//= require test
var str = "body";
```

Then `<%= javascript_tag 'app', :expand => true %>` expands to:
```html

```

The url `/assets/app.js?body=1` should return only the body of app.js, but instead returns the body of test.js concatenated with the body of app.js. As a result, test.js is loaded in the browser twice.

Rather than rewriting the functionality of the Sprockets server in this gem, it is possible to delegate to the Sprockets server. First, duplicate the rack `env` (in case middleware does some crazy things). Second, update `PATH_INFO` to a path that Sprockets can resolve. Finally, invoke the rack `call(env)` method.