File tree 2 files changed +19
-0
lines changed
lib/src/build_system/targets
test/general.shard/build_system/targets
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -354,6 +354,10 @@ class WebServiceWorker extends Target {
354
354
).toString ();
355
355
final String hash = md5.convert (await file.readAsBytes ()).toString ();
356
356
urlToHash[url] = hash;
357
+ // Add an additional entry for the base URL.
358
+ if (globals.fs.path.basename (url) == 'index.html' ) {
359
+ urlToHash['/' ] = hash;
360
+ }
357
361
}
358
362
359
363
final File serviceWorkerFile = environment.outputDir
Original file line number Diff line number Diff line change @@ -462,6 +462,21 @@ void main() {
462
462
// Depends on resource file.
463
463
expect (environment.buildDir.childFile ('service_worker.d' ).readAsStringSync (), contains ('a/a.txt' ));
464
464
}));
465
+
466
+ test ('WebServiceWorker contains baseUrl cache' , () => testbed.run (() async {
467
+ environment.outputDir
468
+ .childFile ('index.html' )
469
+ .createSync (recursive: true );
470
+ await const WebServiceWorker ().build (environment);
471
+
472
+ expect (environment.outputDir.childFile ('flutter_service_worker.js' ), exists);
473
+ // Contains file hash for both `/` and index.html.
474
+ expect (environment.outputDir.childFile ('flutter_service_worker.js' ).readAsStringSync (),
475
+ contains ('"/": "d41d8cd98f00b204e9800998ecf8427e"' ));
476
+ expect (environment.outputDir.childFile ('flutter_service_worker.js' ).readAsStringSync (),
477
+ contains ('"index.html": "d41d8cd98f00b204e9800998ecf8427e"' ));
478
+ expect (environment.buildDir.childFile ('service_worker.d' ), exists);
479
+ }));
465
480
}
466
481
467
482
class MockProcessManager extends Mock implements ProcessManager {}
You can’t perform that action at this time.
0 commit comments