Fix url-filter with file urls on an empty site_url, closes #2189 #2202
Conversation
3d2f6b6
to
507ca07
Fix in 454339b only works on base directory level, pages in subdirectories were still broken. Similar patch for url filter in mkdocs/mkdocs#2202. Ref: 454339b
676984e
to
ff0c93c
|
This should include a test which fails before the change and passes with the change. |
ff0c93c
to
7a82a09
|
@waylan If you can take a quick look, I've reset the PR branch to a single commit capturing the current behavior for the url-filter in a test. Please check if it aligns with your expectations. If everything is fine, I would add more commits:
The second commit changes would be the same as already proposed (507ca07 - might be temporarily go away on Github due to the refresh of the PR), this is only to introduce the tests you've asked for. |
|
As you likely noted, no existing filter tests exist. This is because the one filter we have simply wraps the Finally, I did not expect you to provide the tests without the fix. When I stated that the test should fail before the fix is applied, I simply meant that the test should fail if the fix was removed, not that you provide only the tests first. Sorry if I wasn't clear. |
|
@waylan Could you add more reference to the normalize_url test in utils_tests.py you've commented ("we have tests for that in utils_tests.py"), I can not find it. And no worries, having the tests first is just an intermediate to clarify things upfront, never did any pull request to mkdocs so just stepping in. |
|
Maybe I should have said that we should have tests for that in In any event, at a minimum I would expect the tests added in this PR to be in |
|
I'm assuming this is intended to be a fix for #2189. Adding the link here for later reference. |
|
@waylan Ah okay, now I get it. Let me check what I can add to it, might be that the function is not the right one to patch, as effectively the filter is needed (would be the outer function then). #2189 is good to have referenced, Github would do this automatically as it's in the commit message of the fix. So quick question, would it be acceptable if the test is for the filter function (explicitly), to have it also in the (proper?) If I have the answer to this I should be able to prepare the PR in full. |
|
|
|
Yes, the fix is unique to the filter. This is why I created the file to host filter tests. Thanks for clarifying. The reason why I created tests upfront is just to capture the existing behavior, so the scope of change is more visible. Now seeing how this might came a bit as of a surprise especially at that place. With the discussion so far, I think it is worth to move fixtures to a test of the inner Looking forward to refresh the PR next. |
7a82a09
to
d015930
Some environments have more themes installed which is not an error. Therefore assertion against the expected as subset, not super-set.
Add tests for normalize_url and get_relative_url utiliy functions.
In a new unit-test case via fixtures and matrix of base_url and use_directory_urls: - base_url: - empty - not empty - use_directory_urls: - false - true
d015930
to
aeab718
Previously when "use_directory_urls" was false and "site_url" empty (e.g.
documentation for fs), the link to the home-page / main index was broken
missing /index.html at the end of the url.
Fix is to add the missing index.html in such a case by the url-template-
filter ( {{ ... | url }} ).
NOTE: Some values to the filter are undefined behavior as the filter
will return wrong urls. These cases are considered theoretical
(a file-name must end with a dot and be at the end of value) and not
likely to happen.
Declaring them undefined now, allows to change the implementation
later in a compatible way.
aeab718
to
1c3f6bd
|
@waylan could you add a bit more context about the design decision? Just seeing you added a tag and it would help me to learn more what that relates about. |
|
The tag is just a reminder to myself. At a glance it appears that you've provided a reasonable patch. When I have more time I need to review it in the context of the discussion in #2189. I've removed the [update needed] tag, so I'm not expecting any more work at this time. |
|
Please take whatever time you need to take. I do not see any design decision blocking the merge (it's just a non-design fix), nevertheless take your time with the merge as well. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Previously when "use_directory_urls" was false and "site_url" empty (e.g.
documentation for fs), the link to the home-page / main index was broken
missing /index.html at the end of the url.
Fix is to add the missing index.html in such a case by the url-template-
filter (... | url).
NOTE: Some values to the filter are declared undefined behavior as the
filter will return wrong urls. These cases are considered theoretical
(a file-name must end with a dot and be at the end of value) and not
likely to happen.
Declaring them undefined now, allows to change the implementation
later in a compatible way.