app/helpers/requirejs_helper.rb in requirejs-rails-0.9.2 vs app/helpers/requirejs_helper.rb in requirejs-rails-0.9.3
- old
+ new
@@ -11,11 +11,11 @@
{}.tap do |data|
if name
name += ".js" unless name =~ /\.js$/
data['main'] = _javascript_path(name).
sub(/\.js$/,'').
- sub(baseUrl(name), '').
+ sub(base_url(name), '').
sub(/\A\//, '')
end
data.merge!(yield controller) if block_given?
end.map do |k, v|
@@ -56,11 +56,11 @@
# Override user paths, whose mappings are only relevant in dev mode
# and in the build_config.
run_config['paths'] = paths
end
- run_config['baseUrl'] = baseUrl(name)
+ run_config['baseUrl'] = base_url(name)
html.concat <<-HTML
<script>var require = #{run_config.to_json};</script>
HTML
end
@@ -93,12 +93,12 @@
else
"/assets/#{name}"
end
end
- def baseUrl(js_asset)
+ def base_url(js_asset)
js_asset_path = javascript_path(js_asset)
uri = URI.parse(js_asset_path)
asset_host = uri.host && js_asset_path.sub(uri.request_uri, '')
- [asset_host, Rails.application.config.assets.prefix].join
+ [asset_host, Rails.application.config.relative_url_root, Rails.application.config.assets.prefix].join
end
end