Skip to content

Append fallback extensions when the pre-existing extension has a space#2236

Open
katrinafyi wants to merge 8 commits into
lycheeverse:masterfrom
rina-forks:fix-fallback-extension-spaces
Open

Append fallback extensions when the pre-existing extension has a space#2236
katrinafyi wants to merge 8 commits into
lycheeverse:masterfrom
rina-forks:fix-fallback-extension-spaces

Conversation

@katrinafyi

Copy link
Copy Markdown
Member

Fixes #2235 but I'm not totally sure whether this fix is right.

Maybe fallback-extensions should always just append the fallback extension rather than trying to replace a pre-existing extension? That would be a neater fix to this bug. But maybe some use cases would want a link like x.html to fall back to a x.md file (for example, when doing markdown to html generation). Not sure. In any case, I've added some test cases which show the behaviour.

@mre mre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks. I think the fix looks fine and it would unblock a few users, so I'm happy to merge it.

To your point about appending extensions, I agree that it might break a bunch of use-cases and in general, it would be less intuitive than the current behavior. E.g. as a user, I'd expect the extensions to be exactly the ones I specified in the option, because otherwise I'd have to look at the docs or the source code to find out what's going on. 😉

Comment thread lychee-lib/src/checker/file.rs
Comment thread lychee-lib/src/checker/file.rs Outdated
&& ext.as_encoded_bytes().iter().any(u8::is_ascii_whitespace)
{
let mut ext = ext.to_os_string();
ext.push(".extra-extension");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's perhaps the only little wrinkle. I'm guessing you didn't want to refactor the code too much to fix that issue? It's okay to merge, but can we add a comment about that so we know that we should refactor that in the future?

@katrinafyi katrinafyi Jun 23, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've changed it to avoid the magic string in https://github.com/lycheeverse/lychee/pull/2236/changes/bf010683fb998d148938f7fca89e37a27505723d..caa4e985d434facd15c2c7579754bf02a05c2c0b, let me know if that's better.

And yeah, I wanted to reuse the existing code as much as possible so I just append a new extension first to avoid overwriting the space-containing extension.

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.

fallback-extensions doesn't apply when file name has a dot

2 participants