senchalabs/connect — pull request #995 by jacksonrayhamilton (2014-01-09 21:09:19+00:00)
Title: directory: allow icon reuse

I fixed a bug that caused styling to not be generated for file extensions that reused icons.

I recently increased the pool of possible file extensions that the directory middleware could recognize. Before, file extensions and icons were used on a one-to-one basis; no icons were reused. After I made my addition, the extensions and icons were no longer one-to-one; many icons *were* reused. The CSS-generation algorithm had been written under the assumption that the no icons would be reused, so the resulting styles were sparse. (If the files apple.tar.bz2 and blueberry.tar.gz were in a directory, only the .tar.bz2 files in that directory would have received styling.)

When I made my original commit I included an updated CSS-generation algorithm. However:

- It was rather-naive.
- It included *two* things: a bug fix allowing for icon reuse, and a minor optimization.

However, I believe contributor dougwilson did not notice the bug fix, probably because I failed to mention it in the commit. Instead of merging my updated algorithm, he updated the algorithm with his own optimization, which was better than mine. But this still left the bug intact.

This update fixes the bug while still producing an optimized stylesheet (no rules are duplicated).