Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 9d51ed8

Browse files
committed
Merge pull request #180 from Rakoth/master
Made it possible to use fallbacks for CDN paths
2 parents d894eb3 + 177ab1b commit 9d51ed8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

app/helpers/requirejs_helper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def requirejs_include_tag(name=nil, &block)
5656

5757
if run_config.has_key? 'paths'
5858
# Add paths for assets specified by full URL (on a CDN)
59-
run_config['paths'].each { |k, v| paths[k] = v if v =~ /^https?:/ }
59+
run_config['paths'].each do |k, v|
60+
paths[k] = v if v.is_a?(Array) || v =~ /^https?:/
61+
end
6062
end
6163

6264
# Override user paths, whose mappings are only relevant in dev mode

lib/requirejs/rails/rjs_driver.js.erb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ cdn_pattern = Regexp.new("\\Ahttps?://")
55
modifiedHash = build_config.select { |k, _| k != "modules" }
66
pathsHash = modifiedHash["paths"]
77
modifiedHash["dir"] = build_dir.to_s
8-
modifiedHash["paths"] = Hash[pathsHash
9-
.select do |_, v|
10-
!v.is_a?(Array)
11-
end.map do |k, v|
12-
[k, if !cdn_pattern.match(v) then v else "empty:" end]
8+
modifiedHash["paths"] = Hash[
9+
pathsHash.map do |k, v|
10+
[k, v.is_a?(Array) || cdn_pattern.match(v) ? "empty:" : v]
1311
end
1412
] if !pathsHash.nil?
1513

0 commit comments

Comments
 (0)