aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/style/str.rs2
-rw-r--r--tests/unit/style/str.rs6
2 files changed, 7 insertions, 1 deletions
diff --git a/components/style/str.rs b/components/style/str.rs
index 70fbe538533..92febb40824 100644
--- a/components/style/str.rs
+++ b/components/style/str.rs
@@ -148,6 +148,6 @@ pub fn str_join<I, T>(strs: I, join: &str) -> String
/// Returns true if a given string has a given prefix with case-insensitive match.
pub fn starts_with_ignore_ascii_case(string: &str, prefix: &str) -> bool {
- string.len() > prefix.len() &&
+ string.len() >= prefix.len() &&
string.as_bytes()[0..prefix.len()].eq_ignore_ascii_case(prefix.as_bytes())
}
diff --git a/tests/unit/style/str.rs b/tests/unit/style/str.rs
index 439d32a5f10..154cf894158 100644
--- a/tests/unit/style/str.rs
+++ b/tests/unit/style/str.rs
@@ -35,6 +35,12 @@ pub fn test_str_join_many() {
}
#[test]
+pub fn test_starts_with_ignore_ascii_case_basic() {
+ assert!(starts_with_ignore_ascii_case("-webkit-", "-webkit-"));
+ assert!(starts_with_ignore_ascii_case("-webkit-foo", "-webkit-"));
+}
+
+#[test]
pub fn test_starts_with_ignore_ascii_case_char_boundary() {
assert!(!starts_with_ignore_ascii_case("aaaaa💩", "-webkit-"));
}