Skip to content

apply fallback extensions if directory links resolve to a dir#1826

Merged
mre merged 3 commits intolycheeverse:masterfrom
rina-forks:fix-fallback-on-directories
Aug 29, 2025
Merged

apply fallback extensions if directory links resolve to a dir#1826
mre merged 3 commits intolycheeverse:masterfrom
rina-forks:fix-fallback-on-directories

Conversation

@katrinafyi
Copy link
Member

this restores the 0.19 behaviour. when a directory same_name is next to a file same_name.html, a local link to same_name with fallback extension html will again be able to resolve to same_name.html and see fragments within that HTML file.

in #1777, the fallback extensions were changed to only apply to paths that do not exist, so they would never be applied to directory links. this new PR changes it to also apply fallback extensions when a link would otherwise resolve to a directory. imo this is reasonable and generally desirable (so doesn't need a flag) because directories are treated as having no fragments. so, resolving to real file via a fallback extension (if it exists) will potentially contain more fragments and thus always be "more useful".

also note that fallback extensions will only be used if the directory link resolves to the directory itself. that is, if --index-files is not specified or if . is within the index files list. this means that if you specify --index-files index.html, then no fallback extensions will be applied - as expected.

NOTE: this change is probably risky. because, fallback extensions should only be applied to relative links which are /not/ ending in /. links ending in / should be required to resolve to directories (or their index files). unfortunately, i think the detail of the trailing / is normalised away fairly early in the pipeline. idk what to do here, but i planned to submit this PR and fix the issue firat, and file a bug about the trailing slash after.

related to #1817

this restores the 0.19 behaviour when a directory `same_name` is
next to a file `same_name.html`, a local link to `same_name` with
fallback extension `html` will again be able to resolve to
`same_name.html`.

probably, this always makes sense because directories are treated
as having no fragments, so resolving to real file with a fallback
extension (if it exists) will potentially contain more fragments
and thus be "more useful".

NOTE: this is probably risky. because, fallback extensions should only
be applied to relative links which are /not/ ending in `/`. links
ending in `/` should be required to resolve to directories (or their
index files). unfortunately, i think the detail of the trailing `/`
is normalised away fairly early in the pipeline. idk what to do here,
maybe we just fix this issue for now and file a bug about the trailing
slash.
Copy link
Member

@mre mre left a comment

Choose a reason for hiding this comment

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

Thanks!

@mre mre merged commit 9e867d0 into lycheeverse:master Aug 29, 2025
6 checks passed
@mre mre mentioned this pull request Aug 29, 2025
This was referenced Oct 21, 2025
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.

2 participants