diff --git a/change/react-native-windows-4fa3799d-8c88-4d16-9663-28b1dd4f7b26.json b/change/react-native-windows-4fa3799d-8c88-4d16-9663-28b1dd4f7b26.json new file mode 100644 index 00000000000..505a3f451fd --- /dev/null +++ b/change/react-native-windows-4fa3799d-8c88-4d16-9663-28b1dd4f7b26.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Fix loading images from `file://` URIs", + "packageName": "react-native-windows", + "email": "jthysell@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/vnext/Microsoft.ReactNative/Utils/ImageUtils.cpp b/vnext/Microsoft.ReactNative/Utils/ImageUtils.cpp index 55b5e1d9d40..a9798d8744a 100644 --- a/vnext/Microsoft.ReactNative/Utils/ImageUtils.cpp +++ b/vnext/Microsoft.ReactNative/Utils/ImageUtils.cpp @@ -35,9 +35,7 @@ winrt::IAsyncOperation GetImageStreamAsync(ReactImag winrt::Windows::Foundation::IAsyncOperation getFileSync{nullptr}; if (isFile) { - auto path = winrt::to_string(uri.Path()); - std::replace(path.begin(), path.end(), '/', '\\'); - getFileSync = winrt::Windows::Storage::StorageFile::GetFileFromPathAsync(winrt::to_hstring(path)); + getFileSync = winrt::Windows::Storage::StorageFile::GetFileFromPathAsync(uri.AbsoluteCanonicalUri()); } else { getFileSync = winrt::Windows::Storage::StorageFile::GetFileFromApplicationUriAsync(uri); }