diff --git a/Userland/Libraries/LibCore/ResourceImplementation.cpp b/Userland/Libraries/LibCore/ResourceImplementation.cpp index 580843d5a1..e1852b3aee 100644 --- a/Userland/Libraries/LibCore/ResourceImplementation.cpp +++ b/Userland/Libraries/LibCore/ResourceImplementation.cpp @@ -50,9 +50,11 @@ ErrorOr> ResourceImplementation::load_from_uri(StringVie if (uri.starts_with(file_scheme)) { auto path = uri.substring_view(file_scheme.length()); + auto utf8_path = TRY(String::from_utf8(path)); if (is_directory(path)) - return adopt_ref(*new Resource(TRY(String::from_utf8(path)), Resource::Scheme::File, Resource::DirectoryTag {})); - return adopt_ref(*new Resource(TRY(String::from_utf8(path)), Resource::Scheme::File, TRY(MappedFile::map(path)))); + return adopt_ref(*new Resource(utf8_path, Resource::Scheme::File, Resource::DirectoryTag {})); + auto mapped_file = TRY(MappedFile::map(path)); + return adopt_ref(*new Resource(utf8_path, Resource::Scheme::File, move(mapped_file))); } dbgln("ResourceImplementation: Unknown scheme for {}", uri);