Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat: "a" & "an" both OK for "URL" (#2981)

Andrew Dunbare5d4e050e302
diff --git a/harper-core/src/indefinite_article.rs b/harper-core/src/indefinite_article.rs
index 7e499d041..dbf703869 100644
--- a/harper-core/src/indefinite_article.rs
+++ b/harper-core/src/indefinite_article.rs
@@ -23,7 +23,7 @@ pub fn starts_with_vowel(word: &[char], dialect: Dialect) -> Option<InitialSound
return None;
}
- if matches!(word, ['S', 'Q', 'L'] | ['L', 'E', 'D']) {
+ if matches!(word, ['L', 'E', 'D'] | ['S', 'Q', 'L'] | ['U', 'R', 'L']) {
return Some(InitialSound::Either);
}
diff --git a/harper-core/src/linting/an_a.rs b/harper-core/src/linting/an_a.rs
index 92fed4e45..34f0b8656 100644
--- a/harper-core/src/linting/an_a.rs
+++ b/harper-core/src/linting/an_a.rs
@@ -336,4 +336,18 @@ mod tests {
assert_lint_count("an LED", AnA::new(Dialect::American), 0);
assert_lint_count("a LED", AnA::new(Dialect::American), 0);
}
+
+ #[test]
+ fn allow_a_and_an_for_url() {
+ assert_lint_count(
+ "I pronounce URL as 'yoo-are-ell' so for me it's 'a URL'",
+ AnA::new(Dialect::American),
+ 0,
+ );
+ assert_lint_count(
+ "But some people pronounce it like 'earl' so for them it's 'an URL'",
+ AnA::new(Dialect::American),
+ 0,
+ );
+ }
}