Skip to content

Commit

Permalink
Fix BearQL parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
linw1995 committed Aug 7, 2024
1 parent 2b9a75e commit 04331ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/db/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ pub(crate) mod test {
("./langs/rust//", Path("./langs/rust//".into())),
("//", Path("//".into())),
(".//", Path(".//".into())),
("/blog/", Path("/blog/".into())),
(
"rust | langs go",
Or(
Expand Down
8 changes: 8 additions & 0 deletions src/utils/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub enum Path<'a> {
pub enum RelativePath<'a> {
#[parse("{0}/{1}")]
Join(Keyword<'a>, &'a Self),
#[parse("{0}/")]
NameEndSlash(Keyword<'a>),
#[parse("{0}")]
Name(Keyword<'a>),
#[parse("/")] // for tailing "/", "//" ... syntax
Expand Down Expand Up @@ -145,6 +147,11 @@ fn _path_to_str_parts<'a>(p: Path<'a>, parts: &mut Vec<&'a str>) {
parts.push(item.into());
false
}
RelativePath::NameEndSlash(item) => {
parts.push(item.into());
parts.push("");
false
}
RelativePath::ExtraSlash() => {
parts.push("");
parts.push("");
Expand Down Expand Up @@ -187,6 +194,7 @@ mod test {
r#"title | #rust #langs"#,
r#"title ( #rust #langs )"#,
r#"title ( #rust | #langs )"#,
r#"/blog/"#,
] {
let rv = parse_query(&src, &out_arena, &err_arena);
info!(?rv, ?src, "parsed");
Expand Down

0 comments on commit 04331ca

Please sign in to comment.