base_url configuration setting, closes #394

* base_url configuration setting
* base_url works for static assets as well
This commit is contained in:
Simon Willison 2020-03-24 17:18:43 -07:00 committed by GitHub
commit 7656fd64d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 104 additions and 28 deletions

View file

@ -64,7 +64,7 @@ def test_plugin_extra_js_urls(app_client):
== {
"integrity": "SRIHASH",
"crossorigin": "anonymous",
"src": "https://example.com/jquery.js",
"src": "https://plugin-example.com/jquery.js",
}
]
@ -74,7 +74,7 @@ def test_plugins_with_duplicate_js_urls(app_client):
response = app_client.get("/fixtures")
# This test is a little tricky, as if the user has any other plugins in
# their current virtual environment those may affect what comes back too.
# What matters is that https://example.com/jquery.js is only there once
# What matters is that https://plugin-example.com/jquery.js is only there once
# and it comes before plugin1.js and plugin2.js which could be in either
# order
scripts = Soup(response.body, "html.parser").findAll("script")
@ -82,16 +82,16 @@ def test_plugins_with_duplicate_js_urls(app_client):
# No duplicates allowed:
assert len(srcs) == len(set(srcs))
# jquery.js loaded once:
assert 1 == srcs.count("https://example.com/jquery.js")
assert 1 == srcs.count("https://plugin-example.com/jquery.js")
# plugin1.js and plugin2.js are both there:
assert 1 == srcs.count("https://example.com/plugin1.js")
assert 1 == srcs.count("https://example.com/plugin2.js")
assert 1 == srcs.count("https://plugin-example.com/plugin1.js")
assert 1 == srcs.count("https://plugin-example.com/plugin2.js")
# jquery comes before them both
assert srcs.index("https://example.com/jquery.js") < srcs.index(
"https://example.com/plugin1.js"
assert srcs.index("https://plugin-example.com/jquery.js") < srcs.index(
"https://plugin-example.com/plugin1.js"
)
assert srcs.index("https://example.com/jquery.js") < srcs.index(
"https://example.com/plugin2.js"
assert srcs.index("https://plugin-example.com/jquery.js") < srcs.index(
"https://plugin-example.com/plugin2.js"
)