Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade the package:mime dependency to ^2.0.0 #8378

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ class DartIOHttpRequestData extends NetworkRequest {

@override
String get type {
const defaultType = 'http';
var mime = contentType;
if (mime == null) return 'http';
if (mime == null) {
return defaultType;
}

// Extract the MIME from `contentType`.
// Example: "[text/html; charset-UTF-8]" --> "text/html"
Expand All @@ -156,24 +159,24 @@ class DartIOHttpRequestData extends NetworkRequest {
if (mime.endsWith(']')) {
mime = mime.substring(0, mime.length - 1);
}
return _extensionFromMime(mime);
return _extensionFromMime(mime) ?? defaultType;
}

/// Extracts the extension from [mime], with overrides for shortened
/// extensions of common types (e.g., jpe -> jpeg).
String _extensionFromMime(String mime) {
final extension = extensionFromMime(mime);
if (extension == 'jpe') {
String? _extensionFromMime(String mime) {
final ext = extensionFromMime(mime);
if (ext == 'jpe') {
return 'jpeg';
}
if (extension == 'htm') {
if (ext == 'htm') {
return 'html';
}
// text/plain -> conf
if (extension == 'conf') {
if (ext == 'conf') {
return 'txt';
}
return extension;
return ext;
}

@override
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies:
json_rpc_2: ^3.0.2
logging: ^1.1.1
meta: ^1.9.1
mime: ^1.0.0
mime: ^2.0.0
path: ^1.8.0
perfetto_ui_compiled:
path: ../../third_party/packages/perfetto_ui_compiled
Expand Down
Loading