Skip to content

Change order of SUFFIXES so index.html is served first#3388

Open
RichGibson wants to merge 1 commit intogetpelican:mainfrom
RichGibson:change_suffixes_order
Open

Change order of SUFFIXES so index.html is served first#3388
RichGibson wants to merge 1 commit intogetpelican:mainfrom
RichGibson:change_suffixes_order

Conversation

@RichGibson
Copy link
Copy Markdown

A file named .html should not exist in the output directory.

Somehow I ended up with one, and it was difficult to debug. Changing the order of the SUFFIXES allows the index.html file to be served before checking for .html.

… '.html' exists.

A file named .html should not exist in output. But somehow I ended up with one, and it was difficult to debug. Changing the order of the SUFFIXES allows the index.html file to be served before checking for .html.
Copy link
Copy Markdown
Member

@pauloxnet pauloxnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some test to update to merge this fix?

@RichGibson
Copy link
Copy Markdown
Author

I am not sure what the test would look like, I'm sorry.

@boxydog
Copy link
Copy Markdown
Contributor

boxydog commented Nov 3, 2024

I don't understand why this pull request didn't run tests. When it runs test_server.py I believe it will fail due to these lines:

            # foo.html has precedence over foo/index.html
            path = handler.get_path_that_exists("foo" + suffix)
            self.assertEqual(path, "foo.html")

It failed when I ran it locally.

To prevent your issue, you might have to do something more complicated, such as "if foo is a directory, then look for index.html first"? I don't understand get_path_that_exists deeply.

@boxydog
Copy link
Copy Markdown
Contributor

boxydog commented Nov 3, 2024

FYI the test failure on my box:

        for suffix in ["", "/"]:
            # foo.html has precedence over foo/index.html
            path = handler.get_path_that_exists("foo" + suffix)
>           self.assertEqual(path, "foo.html")
E           AssertionError: 'foo/index.html' != 'foo.html'
E           - foo/index.html
E           ?    ------
E           + foo.html

pelican/tests/test_server.py:48: AssertionError
=========================== short test summary info ============================
FAILED pelican/tests/test_server.py::TestServer::test_get_path_that_exists - ...

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 this pull request may close these issues.

3 participants