Skip to content

Commit f7169b4

Browse files
author
Nick Joyce
committed
Missed a test case for url trailing slash generation
1 parent e5122be commit f7169b4

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

flask_assetrev/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"version",
88
]
99

10-
version_info = (1, 0, 3)
10+
version_info = (1, 0, 4)
1111
version = ".".join(map(str, version_info))
1212

1313
maintainer = "Nick Joyce"

flask_assetrev/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ def get_asset_url(self, asset):
143143
if self.base_path:
144144
asset_file = os.path.join(self.base_path, asset_file)
145145

146+
asset_file = asset_file.lstrip('/')
147+
146148
if self.base_url:
147149
return '/'.join([
148150
self.base_url.rstrip('/'),
149-
asset_file.lstrip('/'),
151+
asset_file,
150152
])
151153

152154
return url_for(

test/test_assetrev.py

+16
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,19 @@ def test_trailing_slash(self):
130130
assetrev.asset_url('app.js'),
131131
'//cdn.myapp.com/foobar/app.deadb33f.js'
132132
)
133+
134+
def test_trailing_slash_path(self):
135+
"""
136+
Handle trailing slashes in ASSETREV_BASE_PATH
137+
"""
138+
app = make_app(config={
139+
'ASSETREV_BASE_PATH': '/foobar',
140+
})
141+
142+
with app.test_request_context():
143+
import flask_assetrev as assetrev
144+
145+
self.assertEqual(
146+
assetrev.asset_url('app.js'),
147+
'http://localhost/static/foobar/app.deadb33f.js'
148+
)

0 commit comments

Comments
 (0)