Permalink
Browse files

Some logical_path values are relative

  • Loading branch information...
1 parent 875aebb commit fc6addfbbee7123e7a026a4972a9385144176f1f @maccman committed May 18, 2012
Showing with 6 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +4 −2 lib/sprockets/commonjs.rb
  3. +1 −1 sprockets-commonjs.gemspec
View
@@ -2,3 +2,4 @@
.bundle
Gemfile.lock
pkg/*
+.DS_Store
@@ -17,12 +17,14 @@ def prepare
def evaluate(scope, locals, &block)
if File.extname(scope.logical_path) == '.module'
- path = scope.logical_path.chomp('.module').inspect
+ path = scope.logical_path
+ path = path.gsub(/^\.?\//, '') # Remove relative paths
+ path = path.chomp('.module') # Remove module ext
scope.require_asset 'sprockets/commonjs'
code = ''
- code << "#{namespace}.define({#{path}:"
+ code << "#{namespace}.define({#{path.inspect}:"
code << 'function(exports, require, module){'
code << data
code << ";}});\n"
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
s.name = "sprockets-commonjs"
- s.version = '0.0.2'
+ s.version = '0.0.4'
s.authors = ["Alex MacCaw"]
s.email = ["info@eribium.org"]
s.homepage = ""

2 comments on commit fc6addf

@josh
Contributor
josh commented on fc6addf May 18, 2012

Thats a bug then. All logical paths should not having a leading slash or any relative dots.

@maccman
Owner

We were finding paths in 'vendor' had a leading './'. Probably quite hard to reproduce though.

Please sign in to comment.