miracle2k / flask-assets

Flask webassets integration.
BSD 2-Clause "Simplified" License
454 stars 100 forks source link

Fix compatibility issue on Windows #167

Closed zhaoblake closed 9 months ago

zhaoblake commented 9 months ago

Fix compatibility issue when converting a Windows path to a URL.

On Windows, the output of the following code is ['/static/foo%5Cbar'], which works fine on Linux as ['/static/foo/bar']. The issue arises from the difference between Windows' path separator (\\) and the URL separator (/), well on Linux, path separator is same as the URL separator.

from flask import Flask
from flask_assets import Environment, Bundle

app = Flask(__name__)
env = Environment(app)
print(Bundle("foo/bar", env=env).urls())  
greyli commented 9 months ago

Could you add some tests for this fix?

zhaoblake commented 9 months ago

Could you add some tests for this fix?

Actually there is already a test related to this, it failed on Windows Platform due to this compatibility issue. I think it is not necessary to add a new one.

greyli commented 9 months ago

I see. I just enabled the CI for Windows.

Merged, thanks!