Skip to content

Commit 83d560e

Browse files
committed
document the prefix method
1 parent 9f9f11e commit 83d560e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use addr::{parse_domain_name, parse_dns_name};
1414
let domain = parse_domain_name("www.example.com")?;
1515
assert_eq!(domain.root(), Some("example.com"));
1616
assert_eq!(domain.suffix(), "com");
17+
assert_eq!(domain.prefix(), Some("www"));
1718

1819
let domain = parse_domain_name("www.食狮.中国")?;
1920
assert_eq!(domain.root(), Some("食狮.中国"));

tests/integration.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ fn addr_parsing() {
6161
});
6262

6363
ctx.it("should allow sub-domains", |_| {
64-
assert!(List.parse_domain_name("www.example.com.").is_ok())
64+
let domain = List.parse_domain_name("www.example.com.").unwrap();
65+
assert_eq!(domain.suffix(), "com.");
66+
assert_eq!(domain.root(), Some("example.com."));
67+
assert_eq!(domain.prefix(), Some("www"));
6568
});
6669

6770
ctx.it("should allow IDNs", |_| {

0 commit comments

Comments
 (0)