Skip to content

Commit ae6885f

Browse files
Ensure we hoist paths containing glob characters
1 parent b828f81 commit ae6885f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

crates/oxide/src/glob.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub fn optimize_public_source_entry(source: &mut PublicSourceEntry) {
8686
None => base,
8787
};
8888

89+
// TODO: If the base does not exist on disk, try removing the last slash and try again.
8990
let base = match dunce::canonicalize(&base) {
9091
Ok(base) => base,
9192
Err(err) => {

crates/oxide/tests/scanner.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,33 @@ mod scanner {
836836
assert_eq!(candidates, vec!["content-['keep-me.html']"]);
837837
}
838838

839+
#[test]
840+
fn test_works_with_filenames_containing_glob_characters() {
841+
// Create a temporary working directory
842+
let dir = tempdir().unwrap().into_path();
843+
844+
// Create files
845+
create_files_in(
846+
&dir,
847+
&[
848+
("src/app/[foo]/ignore-me.html", "content-['ignore-me.html']"),
849+
("src/app/[foo]/keep-me.html", "content-['keep-me.html']"),
850+
],
851+
);
852+
853+
let sources = vec![
854+
PublicSourceEntry::from_pattern(dir.clone(), "@source '**/*'"),
855+
PublicSourceEntry::from_pattern(
856+
dir.clone(),
857+
"@source not 'src/app/[foo]/ignore*.html'",
858+
),
859+
];
860+
861+
let candidates = Scanner::new(sources.clone()).scan();
862+
863+
assert_eq!(candidates, vec!["content-['keep-me.html']"]);
864+
}
865+
839866
#[test]
840867
fn test_foo_bar() {
841868
// Create a temporary working directory

0 commit comments

Comments
 (0)