Skip to content

Commit e5b37ee

Browse files
dphmsurma
andcommitted
Handle non-utf8 paths and files without extensions
Co-authored-by: Surma <[email protected]>
1 parent 25394d1 commit e5b37ee

File tree

1 file changed

+2
-2
lines changed
  • graphql_client_codegen/src

1 file changed

+2
-2
lines changed

graphql_client_codegen/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ fn get_set_schema_from_file(schema_path: &std::path::Path) -> Schema {
8080
get_set_cached(&SCHEMA_CACHE, schema_path, move || {
8181
let schema_extension = schema_path
8282
.extension()
83-
.and_then(std::ffi::OsStr::to_str)
84-
.unwrap_or("INVALID");
83+
.map(|ext| ext.to_str().expect("Path must be valid UTF-8"))
84+
.unwrap_or("<no extension>");
8585
let schema_string = read_file(schema_path).unwrap();
8686
match schema_extension {
8787
"graphql" | "gql" => {

0 commit comments

Comments
 (0)