Fix `uri_to_pattern` function incorrectly prepending `/` to all patterns
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16
- Forks
- 3
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 121
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
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.
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.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100