Fix `uri_to_pattern` function incorrectly prepending `/` to all patterns
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start in crates/jp_attachment_file_content/src/lib.rs around lines 163-173 and inspect the uri_to_pattern function. Compare its handling of relative and root-level gitignore patterns with the documented semantics. Done means patterns such as *.md, /foo, foo/bar, and /foo/bar retain their intended matching scope.
Written by the indexing model from the issue text.
Description
The uri_to_pattern function in jp_attachment_file_content always prepends a / to patterns, but this changes the semantic meaning of gitignore patterns since leading slashes have specific meaning in gitignore syntax.
Expected Behavior
According to gitignore documentation, patterns with and without leading slashes have different meanings:
foomatches any file or directory namedfooanywhere in the tree/foomatches only files or directories namedfooat the root levelfoo/barmatchesbarinside any directory namedfoo/foo/barmatchesbaronly insidefooat the root level
The function should preserve the original pattern structure instead of always making patterns absolute.
Actual Behavior
The current uri_to_pattern function always prepends a / to patterns via:
if !path.starts_with('/') {
path = format!("/{path}");
}
This means that a pattern like *.md becomes /*.md, which only matches markdown files at the root level instead of matching them anywhere in the tree.
Proposed Solution
Modify the uri_to_pattern function to preserve the original pattern semantics. The function should only prepend a / when the URI explicitly indicates a root-level pattern, not as a default behavior.
One approach is to check if the URI path already starts with / and only then treat it as a root-level pattern. For relative patterns, preserve them as-is.
Resources
- Dominant language
- Rust
- Stars
- 16
- Forks
- 3
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 121
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dcdpr/jp
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100