Fix Context#logical_path when path contains periods #299

Merged
merged 1 commit into from Mar 27, 2012

3 participants

@GUI

Without this, the logical_path only grabbed up up until the first period encountered. So if you happened to have a file like jquery.mobile-1.0.1/jquery.mobile-1.0.1.js it's logical path was being interpreted as just jquery instead of jquery.mobile-1.0.1/jquery.mobile-1.0.1.

I'm not super familiar with the inner-workings of sprockets, so I'm not entirely sure where Context#logical_path is being used, but sprockets-urlrewriter uses this logical_path method and expects it to be the relative path to the asset file. This was obviously leading to strange results since parts of the path might be missing if the file name or path happened to contain periods. And I didn't see any other obvious way to get this type of relative path to the asset file inside a Processor subclass.

@GUI GUI Fix Context#logical_path when path contains periods.
Without this, the `logical_path` only grabbed up up until the first period encountered. So if you happened to have a file like `jquery.mobile-1.0.1/jquery.mobile-1.0.1.js` it's logical path was being interpreted as just `jquery` instead of `jquery.mobile-1.0.1/jquery.mobile-1.0.1`.
abe94ac
@josh josh commented on the diff Mar 3, 2012
lib/sprockets/context.rb
@@ -53,7 +53,7 @@ def root_path
# # => 'application'
#
def logical_path
- @logical_path[/^([^.]+)/, 0]
+ @logical_path.chomp(File.extname(@logical_path))
@josh
josh added a note Mar 3, 2012

This doesn't seem right.

Context#logical_path should == Asset#logical_path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@josh josh merged commit d3fcd85 into sstephenson:master Mar 27, 2012
@guilleiguaran

@josh looks like this is causing rails/rails#8099, can you help us to find what's the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment