mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Plugin static assets support both hyphens and underscores in names
Closes #611
This commit is contained in:
parent
ffae2f0ecd
commit
ed57e4f990
2 changed files with 12 additions and 3 deletions
|
|
@ -612,8 +612,17 @@ class Datasette:
|
|||
# Mount any plugin static/ directories
|
||||
for plugin in get_plugins(pm):
|
||||
if plugin["static_path"]:
|
||||
modpath = "/-/static-plugins/{}/(?P<path>.*)$".format(plugin["name"])
|
||||
add_route(asgi_static(plugin["static_path"]), modpath)
|
||||
add_route(
|
||||
asgi_static(plugin["static_path"]),
|
||||
"/-/static-plugins/{}/(?P<path>.*)$".format(plugin["name"]),
|
||||
)
|
||||
# Support underscores in name in addition to hyphens, see https://github.com/simonw/datasette/issues/611
|
||||
add_route(
|
||||
asgi_static(plugin["static_path"]),
|
||||
"/-/static-plugins/{}/(?P<path>.*)$".format(
|
||||
plugin["name"].replace("-", "_")
|
||||
),
|
||||
)
|
||||
add_route(
|
||||
JsonDataView.as_asgi(self, "metadata.json", lambda: self._metadata),
|
||||
r"/-/metadata(?P<as_format>(\.json)?)$",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue