rstacruz / sinatra-assetpack

Package your assets transparently in Sinatra.
http://ricostacruz.com/sinatra-assetpack/
MIT License
541 stars 97 forks source link

Asset configuration breaks in sinatra when you have a filename with too many dots #78

Closed syelle closed 11 years ago

syelle commented 11 years ago

When you try to get the assetpack to compile a file with more than 2 dots in the name, the file generates with an error indicating that Sinatra received a 404 when trying to retrieve the original asset.

Files with 2 dots in the names appears to be fine, however.

We've worked around the issue by replacing dots with dashes.

Example

    js :app, '/js/app.js', [
      '/js/jquery-1.8.2-min.js',
      '/js/application.js',
    ]

Error

<!DOCTYPE html>
<html>
<head>
  <style type="text/css">
  body { text-align:center;font-family:helvetica,arial;font-size:22px;
    color:#888;margin:20px}
  #c {margin:0 auto;width:500px;text-align:left}
  </style>
</head>
<body>
  <h2>Sinatra doesn&rsquo;t know this ditty.</h2>
  <img src='http://example.org/__sinatra__/404.png'&gt
  <div id="c">
    Try this:
    <pre>get '/js/jquery-1.8.2-min.js' do
  "Hello World"
end</pre>
  </div>
</body>
</html>
j15e commented 11 years ago

I made a fix for a similar issue on the feature/md5 branch at a74c12b1a912df33391a7fea27a2239fc724eeb5 might be related.

wakatara commented 11 years ago

(just jumping in from Code Triage) email.

Yep, this appears to fix the issue. Just looking like it needs to be merged in. @syelle, can you confirm the branch fixes the problem and we can close this in as duplicate/fixed?

j15e commented 11 years ago

P.S. the md5 branch isn't merged yet because there is an issue when running tests on travis-ci. Haven't got time to track it down yet.

syelle commented 11 years ago

@tundramonkey We've not tested that branch to see if it fixed things, but based on the commit diff @j15e posted it seems directed at fixing things with the destination files (i.e. making sure the MD5 hash is in all test cases and that the gem doesn't serve a file if you append a few etra characters to the hash). I didn't see anything that jumped out as addressing our issue specifically, which is that you cannot specify a source file with more than two dots in the name.

j15e commented 11 years ago

I have an app here that uses http://localhost:9292/js/vendor/jquery-1.9.1.min.js and it works.

I made a specific test case for this here and I am pretty sure this was fixed in the master branch earlier with this commit. I added the test because it would not work in the pull request made for MD5 hashes at fist (now fixed too on my branch md5 I think).