staticjinja
staticjinja copied to clipboard
staticpaths incorrectly identifies files
Given the code shown below and a file structure of:
- policies/document_1.pdf
- policies.html
from staticjinja import Site
if __name__ == "__main__":
staticpaths = [
"policies/",
]
site = Site.make_site(
staticpaths=staticpaths,
)
site.render()
Staticjinja is incorrectly identifying policies.html as a staticfile, whereas only the directory policies and it's subcomponents should be marked as a static file.
The culprit seems to be https://github.com/staticjinja/staticjinja/blob/main/staticjinja/staticjinja.py#L344
The simple test below fails:
from pathlib import Path
# Create test file
filename = "readme.md"
Path(filename).touch()
staticpaths = ["readme/"]
for path in staticpaths:
assert Path(path).exists() is False
path = Path(filename).as_posix()
# Fails assertion
assert any(path.startswith(Path(sp).as_posix()) for sp in staticpaths) is False