Skip to content

--default-extension is not extracting links without URL-scheme #2244

Description

@nobkd

PR that introduced the feature: #1842

I found this, while looking for --fallback-extensions for #2235 / #1503 (comment), but wanted to make sure it's not just my user error. Basically means, I'm not depending on this.


--default-extension is not extracting links without URL-scheme.
TLDR: Maybe the flag is never used properly (on files?) / the file_type_hint gets lost?

$ lychee --version
lychee 0.24.2

Test case:

# `my-extensionless-file`

[link 1 with scheme](https://lychee.cli.rs/)
[link 2 with scheme](mailto:44443899+nobkd@users.noreply.github.com)
[schemeless link 1](file.txt)
[schemeless link 2](//otherfile.txt)

Also create a file with the same content but with an extension, as my-extension-file.md.

$ lychee my-extensionless-file --root-dir . --default-extension md --dump --include-mail
https://lychee.cli.rs/
mailto:44443899+nobkd@users.noreply.github.com

vs with the extension:

$ lychee my-extension-file.md --root-dir . --default-extension md --dump --include-mail
https://lychee.cli.rs/
mailto:44443899+nobkd@users.noreply.github.com
file:///path/to/file.txt
file://otherfile.txt/

Also without --default-extension md gives the same result as with it:

$ lychee my-extensionless-file --root-dir . --dump --include-mail
https://lychee.cli.rs/
mailto:44443899+nobkd@users.noreply.github.com

Additional:

It feels like the file is just treated like unknown file format.
Soooo maybe the file is not really processed as markdown even with the flag?

The test test_default_extension_option also just checks the links for the remote link.


Slightly off-topic, but some remarks:

I at first thought, --default-extension was like --fallback-extensions. Maybe the description could be worded a bit better to clarify it's not. Maybe it's just a me problem though. 🤷

For example: Maybe don't call it "applied"?

This is the default file extension that is applied to files without an extension.

Something like the following could be added:

--default-extension is a flag to interpret (treat) extension-less input files as the provided format, for link extraction, it has no influence on finding files by extension-less link.

or

This is only used to handle file content, and does not append the extension to locate files. For that, see --fallback-extensions

But this were just two ideas, not sure if they're any good.

This of course only makes sense, when I understood the flag correctly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions