Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staticpaths incorrectly identifies files #164

Open
alex-way opened this issue Nov 9, 2021 · 1 comment
Open

staticpaths incorrectly identifies files #164

alex-way opened this issue Nov 9, 2021 · 1 comment

Comments

@alex-way
Copy link

alex-way commented Nov 9, 2021

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.

@alex-way
Copy link
Author

alex-way commented Nov 9, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant