File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ fn read_snippet(path: &Path, filetype: &str) -> Vec<Snippet> {
111111fn get_file_basename ( path : String ) -> String {
112112 let paths = path. split ( "/" ) ;
113113 match paths. last ( ) {
114- Some ( filename) => match filename. find ( "." ) {
114+ Some ( filename) => match filename. rfind ( "." ) {
115115 Some ( index) => filename[ 0 ..index] . to_string ( ) ,
116116 None => filename. to_string ( ) ,
117117 } ,
@@ -149,6 +149,12 @@ mod test {
149149
150150 let filename = get_file_basename ( "102938 !#@#! abcdqweio.txt" . to_string ( ) ) ;
151151 assert_eq ! ( "102938 !#@#! abcdqweio" , filename) ;
152+
153+ let filename = get_file_basename ( "hello" . to_string ( ) ) ;
154+ assert_eq ! ( "hello" , filename) ;
155+
156+ let filename = get_file_basename ( "hello.world.txt" . to_string ( ) ) ;
157+ assert_eq ! ( "hello.world" , filename) ;
152158 }
153159
154160 #[ test]
You can’t perform that action at this time.
0 commit comments