Skip to content

Conversation

@katrinafyi
Copy link
Contributor

now, when providing an input with glob characters but an invalid glob pattern, this will cause a "cannot parse inputs" error rather than erroring out later during link checking. this makes use of the existing ErrorKind::InvalidGlobPattern error case.

for example, a glob with unbalanced brackets is invalid and now looks like this:

$ cargo run -- 'noasdjfi/['
Error: Cannot parse inputs from arguments

Caused by:
    0: UNIX glob pattern is invalid
    1: Pattern syntax error near position 9: invalid range pattern

i've also added some TODO notes which would make the logic neater. i didn't do those refactors in this PR because i am mindful of another currently-open (and much bigger) PR which touches these lines (https://www.github.com/lycheeverse/lychee/pull/1837)

i wonder if the reason FsGlob stores strings rather than a Pattern is for flexibility to switch to different glob packages.

this PR was prompted by findings in #1864 (comment)

now, when providing an input with glob characters but an invalid glob
pattern, this will cause a "cannot parse inputs" error rather than
erroring out later during link checking. this makes use of the
existing ErrorKind::InvalidGlobPattern error case.

for example, a glob with unbalanced brackets is invalid and now looks
like this:
```console
$ cargo run -- 'noasdjfi/['
Error: Cannot parse inputs from arguments

Caused by:
    0: UNIX glob pattern is invalid
    1: Pattern syntax error near position 9: invalid range pattern
```

i've also added some TODO notes which would make the logic neater.
i didn't do those refactors in this PR because i am mindful of another
currently-open (and much bigger) PR which touches these lines
(https://www.github.com/lycheeverse/lychee/pull/1837)

i wonder if the reason FsGlob stores strings rather than a Pattern is
for flexibility to switch to different glob packages.

this PR was prompted by findings in
lycheeverse#1864 (comment)
@thomas-zahner
Copy link
Member

i wonder if the reason FsGlob stores strings rather than a Pattern is for flexibility to switch to different glob packages.

Good question, I wouldn't think so but then I'm not the author. @mre might know the answer to that.
Have you tried to change the type to Pattern? I would much prefer that if it is possible without too much effort.

Otherwise I have no objections to this PR.

@thomas-zahner thomas-zahner force-pushed the master branch 2 times, most recently from fcdf77c to e0912ab Compare October 21, 2025 12:53
@katrinafyi
Copy link
Contributor Author

Have you tried to change the type to Pattern?

If you're asking me, I haven't tried. I think the change would be pretty easy. But it's the kind of thing which is so obvious that if it hasn't been done already, then there's probably a logical reason why it hasn't. That's my reasoning at least.

If you're asking @ mre, then we have to wait for him :)

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