Skip to content

Commit

Permalink
fix(package_info_plus): add support for file scheme on web (#3345)
Browse files Browse the repository at this point in the history
Co-authored-by: Alvaro Prado <[email protected]>
  • Loading branch information
alvarobcprado and Alvaro Prado authored Nov 7, 2024
1 parent e38b4c3 commit 2d69758
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
);
});
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2d69758

Please sign in to comment.