Skip to content

Commit

Permalink
Handle non-utf8 paths and files without extensions
Browse files Browse the repository at this point in the history
Co-authored-by: Surma <[email protected]>
  • Loading branch information
dphm and surma committed Jan 8, 2024
1 parent e03069e commit d3a0436
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions graphql_client_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ fn get_set_schema_from_file(schema_path: &std::path::Path) -> Schema {
get_set_cached(&SCHEMA_CACHE, schema_path, move || {
let schema_extension = schema_path
.extension()
.and_then(std::ffi::OsStr::to_str)
.unwrap_or("INVALID");
.map(|ext| ext.to_str().expect("Path must be valid UTF-8"))
.unwrap_or("<no extension>");
let schema_string = read_file(schema_path).unwrap();
match schema_extension {
"graphql" | "gql" => {
Expand Down

0 comments on commit d3a0436

Please sign in to comment.