mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Remove is_some() from mime_classifier.rs and fix typo "uknown" -> "unknown"
This commit is contained in:
parent
dcb1237bb5
commit
468faf9d43
1 changed files with 23 additions and 34 deletions
|
@ -29,7 +29,7 @@ impl MIMEClassifier {
|
||||||
}
|
}
|
||||||
Some((ref media_type, ref media_subtype)) => {
|
Some((ref media_type, ref media_subtype)) => {
|
||||||
match (&**media_type, &**media_subtype) {
|
match (&**media_type, &**media_subtype) {
|
||||||
("uknown", "unknown") | ("application", "uknown") | ("*", "*") => {
|
("unknown", "unknown") | ("application", "unknown") | ("*", "*") => {
|
||||||
return self.sniff_unknown_type(!no_sniff,data);
|
return self.sniff_unknown_type(!no_sniff,data);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -48,24 +48,22 @@ impl MIMEClassifier {
|
||||||
return self.feeds_classifier
|
return self.feeds_classifier
|
||||||
.classify(data)
|
.classify(data)
|
||||||
.or(supplied_type.clone());
|
.or(supplied_type.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
if &**media_type == "image" {
|
||||||
|
if let Some(tp) = self.image_classifier.classify(data) {
|
||||||
|
return Some(tp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if &**media_type == "image" {
|
match (&**media_type, &**media_subtype) {
|
||||||
let tp = self.image_classifier.classify(data);
|
("audio", _) | ("video", _) | ("application", "ogg") => {
|
||||||
if tp.is_some() {
|
if let Some(tp) = self.audio_video_classifer.classify(data) {
|
||||||
return tp;
|
return Some(tp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
match (&**media_type, &**media_subtype) {
|
}
|
||||||
("audio", _) | ("video", _) | ("application", "ogg") => {
|
|
||||||
let tp = self.audio_video_classifer.classify(data);
|
|
||||||
if tp.is_some() {
|
|
||||||
return tp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,23 +86,14 @@ impl MIMEClassifier {
|
||||||
fn sniff_unknown_type(&self, sniff_scriptable: bool, data: &Vec<u8>) ->
|
fn sniff_unknown_type(&self, sniff_scriptable: bool, data: &Vec<u8>) ->
|
||||||
Option<(String,String)> {
|
Option<(String,String)> {
|
||||||
if sniff_scriptable {
|
if sniff_scriptable {
|
||||||
let tp = self.scriptable_classifier.classify(data);
|
self.scriptable_classifier.classify(data)
|
||||||
if tp.is_some() {return tp;}
|
} else {
|
||||||
}
|
None
|
||||||
|
}.or_else(|| self.plaintext_classifier.classify(data))
|
||||||
let tp = self.plaintext_classifier.classify(data);
|
.or_else(|| self.image_classifier.classify(data))
|
||||||
if tp.is_some() {return tp;}
|
.or_else(|| self.audio_video_classifer.classify(data))
|
||||||
|
.or_else(|| self.archive_classifer.classify(data))
|
||||||
let tp = self.image_classifier.classify(data);
|
.or_else(|| self.binary_or_plaintext.classify(data))
|
||||||
if tp.is_some() {return tp;}
|
|
||||||
|
|
||||||
let tp = self.audio_video_classifer.classify(data);
|
|
||||||
if tp.is_some() {return tp;}
|
|
||||||
|
|
||||||
let tp = self.archive_classifer.classify(data);
|
|
||||||
if tp.is_some() {return tp;}
|
|
||||||
|
|
||||||
self.binary_or_plaintext.classify(data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sniff_text_or_data(&self, data: &Vec<u8>) -> Option<(String, String)> {
|
fn sniff_text_or_data(&self, data: &Vec<u8>) -> Option<(String, String)> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue