Skip to content

Commit

Permalink
fix: prefix . for fully qualified field names was not working (#34)
Browse files Browse the repository at this point in the history
Sometimes, user prefer to use `.` as prefix for fully qualified field
names. This fixes the `split_package_identifier` to take into account
this during splitting.

This potentially fixes: #31
  • Loading branch information
coder3101 authored Oct 5, 2024
1 parent 247da66 commit 340d306
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ pub fn is_inner_identifier(s: &str) -> bool {
}

pub fn split_identifier_package(s: &str) -> (&str, &str) {
// trim beginning dots, some use `.` prefix for fully qualified field names
let s = s.trim_start_matches(".");
if is_inner_identifier(s) || !s.contains('.') {
return ("", s);
}
Expand Down Expand Up @@ -76,6 +78,10 @@ mod test {
split_identifier_package("com.book.Book"),
("com.book", "Book")
);
assert_eq!(
split_identifier_package(".com.book.Book"),
("com.book", "Book")
);
assert_eq!(
split_identifier_package("com.book.Book.Author"),
("com.book", "Book.Author")
Expand Down

0 comments on commit 340d306

Please sign in to comment.