This repository was archived by the owner on Mar 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ def build_config
108
108
mod [ 'name' ] = 'almond'
109
109
mod [ 'include' ] = name
110
110
end
111
+ self . rewrite_urls_in_paths self [ :build_config ]
111
112
end
112
113
self [ :build_config ]
113
114
end
@@ -146,5 +147,13 @@ def asset_allowed?(asset)
146
147
accum || ( matcher =~ asset )
147
148
end ? true : false
148
149
end
150
+
151
+ def rewrite_urls_in_paths ( cfg )
152
+ if cfg . has_key? 'paths'
153
+ cfg [ 'paths' ] = cfg [ 'paths' ] . each_with_object ( { } ) do |( k , v ) , h |
154
+ h [ k ] = ( v =~ /^https?:/ ) ? 'empty:' : v
155
+ end
156
+ end
157
+ end
149
158
end
150
159
end
Original file line number Diff line number Diff line change @@ -80,7 +80,27 @@ def setup
80
80
assert_nil @cfg . build_config [ 'priority' ]
81
81
end
82
82
83
- ## Almond tests
83
+ test "build config should replace urls in paths with 'empty:'" do
84
+ @cfg . user_config = { 'paths' =>
85
+ {
86
+ 'jquery' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ,
87
+ 'jqueryssl' => 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'
88
+ }
89
+ }
90
+ assert_equal 'empty:' , @cfg . build_config [ 'paths' ] [ 'jquery' ]
91
+ assert_equal 'empty:' , @cfg . build_config [ 'paths' ] [ 'jqueryssl' ]
92
+ end
93
+
94
+ test "build_config should not modify non-urls in paths" do
95
+ @cfg . user_config = { 'paths' =>
96
+ {
97
+ 'foo' => 'components/foo'
98
+ }
99
+ }
100
+ assert_equal 'components/foo' , @cfg . build_config [ 'paths' ] [ 'foo' ]
101
+ end
102
+
103
+ ## Almond-specific tests
84
104
test "build_config with almond should accept one module" do
85
105
@cfg . loader = :almond
86
106
@cfg . user_config = { 'modules' => [ { 'name' => 'foo' } ] }
You can’t perform that action at this time.
0 commit comments