File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -144,7 +144,10 @@ def get_asset_url(self, asset):
144
144
asset_file = os .path .join (self .base_path , asset_file )
145
145
146
146
if self .base_url :
147
- return self .base_url + asset_file
147
+ return '/' .join ([
148
+ self .base_url .rstrip ('/' ),
149
+ asset_file .lstrip ('/' ),
150
+ ])
148
151
149
152
return url_for (
150
153
'static' ,
Original file line number Diff line number Diff line change @@ -112,3 +112,21 @@ def test_missing_asset(self):
112
112
asset_url ('missing.js' )
113
113
114
114
self .assertEqual (ctx .exception .asset_file , 'missing.js' )
115
+
116
+ # https://github.com/njoyce/flask-assetrev/issues/1
117
+ def test_trailing_slash (self ):
118
+ """
119
+ Handle trailing slashes in config
120
+ """
121
+ app = make_app (config = {
122
+ 'ASSETREV_BASE_URL' : '//cdn.myapp.com/' ,
123
+ 'ASSETREV_BASE_PATH' : '/foobar' ,
124
+ })
125
+
126
+ with app .test_request_context ():
127
+ import flask_assetrev as assetrev
128
+
129
+ self .assertEqual (
130
+ assetrev .asset_url ('app.js' ),
131
+ '//cdn.myapp.com/foobar/app.deadb33f.js'
132
+ )
You can’t perform that action at this time.
0 commit comments