diff --git a/packages/package_info_plus/package_info_plus/example/integration_test/package_info_plus_web_test.dart b/packages/package_info_plus/package_info_plus/example/integration_test/package_info_plus_web_test.dart index e01210bc47..b9bf613d10 100644 --- a/packages/package_info_plus/package_info_plus/example/integration_test/package_info_plus_web_test.dart +++ b/packages/package_info_plus/package_info_plus/example/integration_test/package_info_plus_web_test.dart @@ -217,6 +217,25 @@ void main() { 'chrome-extension://abcdefgh/a/b/c/version.json?cachebuster=1'), ); }); + + testWidgets('Get correct versionJsonUrl for file', (tester) async { + expect( + plugin.versionJsonUrl('file://abcdefgh', 1), + Uri.parse('file:///version.json?cachebuster=1'), + ); + expect( + plugin.versionJsonUrl('file://abcdefgh/a/b/c', 1), + Uri.parse('file:///a/b/c/version.json?cachebuster=1'), + ); + expect( + plugin.versionJsonUrl('file://abcdefgh/#my-page', 1), + Uri.parse('file:///version.json?cachebuster=1'), + ); + expect( + plugin.versionJsonUrl('file://abcdefgh/a/b/c/#my-page', 1), + Uri.parse('file:///a/b/c/version.json?cachebuster=1'), + ); + }); }, ); diff --git a/packages/package_info_plus/package_info_plus/lib/src/package_info_plus_web.dart b/packages/package_info_plus/package_info_plus/lib/src/package_info_plus_web.dart index 0be152e430..abae97b8e4 100644 --- a/packages/package_info_plus/package_info_plus/lib/src/package_info_plus_web.dart +++ b/packages/package_info_plus/package_info_plus/lib/src/package_info_plus_web.dart @@ -123,6 +123,8 @@ extension _UriOrigin on Uri { String get _origin { if (isScheme('chrome-extension')) { return '$scheme://$host'; + } else if (isScheme('file')) { + return '$scheme://'; } return origin; }