Unverified Commit a4093edb authored by Mehmet Oguz Derin's avatar Mehmet Oguz Derin Committed by GitHub

Fix Path Separator in Service Workers (#50154)

parent 4485a65e
......@@ -314,7 +314,7 @@ class WebServiceWorker extends Target {
for (File file in contents)
// Do not force caching of source maps.
if (!file.path.endsWith('main.dart.js.map'))
'/${globals.fs.path.relative(file.path, from: environment.outputDir.path)}':
'/${globals.fs.path.toUri(globals.fs.path.relative(file.path, from: environment.outputDir.path)).toString()}':
md5.convert(await file.readAsBytes()).toString(),
};
final File serviceWorkerFile = environment.outputDir
......
......@@ -405,7 +405,7 @@ void main() {
});
test('WebServiceWorker generates a service_worker for a web resource folder', () => testbed.run(() async {
environment.outputDir.childFile('a.txt')
environment.outputDir.childDirectory('a').childFile('a.txt')
..createSync(recursive: true)
..writeAsStringSync('A');
await const WebServiceWorker().build(environment);
......@@ -413,10 +413,10 @@ void main() {
expect(environment.outputDir.childFile('flutter_service_worker.js'), exists);
// Contains file hash.
expect(environment.outputDir.childFile('flutter_service_worker.js').readAsStringSync(),
contains('"/a.txt": "7fc56270e7a70fa81a5935b72eacbe29"'));
contains('"/a/a.txt": "7fc56270e7a70fa81a5935b72eacbe29"'));
expect(environment.buildDir.childFile('service_worker.d'), exists);
// Depends on resource file.
expect(environment.buildDir.childFile('service_worker.d').readAsStringSync(), contains('a.txt'));
expect(environment.buildDir.childFile('service_worker.d').readAsStringSync(), contains('a/a.txt'));
}));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment