fix: apple really wants this file as json (#4893)
diff --git a/app_dart/lib/src/request_handling/static_file_handler.dart b/app_dart/lib/src/request_handling/static_file_handler.dart index 6e20a1b..45864e9 100644 --- a/app_dart/lib/src/request_handling/static_file_handler.dart +++ b/app_dart/lib/src/request_handling/static_file_handler.dart
@@ -39,6 +39,10 @@ '.smcbin': 'application/octet-stream', }; + const mimeFileMap = { + 'apple-app-site-association': 'application/json', + }; + final resultPath = filePath == '/' ? '/index.html' : filePath; /// The file path in app_dart to the files to serve @@ -46,6 +50,7 @@ final file = fs.file('$basePath$resultPath'); if (file.existsSync()) { final mimeType = + mimeFileMap[path.basename(file.path)] ?? mimeTypeMap[path.extension(file.path)] ?? lookupMimeType(resultPath) ?? 'application/octet-stream';
diff --git a/app_dart/test/request_handling/static_file_handler_test.dart b/app_dart/test/request_handling/static_file_handler_test.dart index 47f4fc1..69b54aa 100644 --- a/app_dart/test/request_handling/static_file_handler_test.dart +++ b/app_dart/test/request_handling/static_file_handler_test.dart
@@ -124,5 +124,21 @@ expect(body.contentType, isNotNull); expect(body.contentType!.mimeType, 'application/octet-stream'); }); + + test('Basename overrides', () async { + fs.file('build/web/apple-app-site-association').writeAsStringSync('abc'); + final staticFileHandler = StaticFileHandler( + '/apple-app-site-association', + config: config, + fs: fs, + ); + + final body = await tester.get(staticFileHandler); + expect(body, isNotNull); + final response = await decodeHandlerBody(body); + expect(response, 'abc'); + expect(body.contentType, isNotNull); + expect(body.contentType!.mimeType, 'application/json'); + }); }); }