Skip to content

Commit 4301610

Browse files
committed
fix: parse path with whitespace
- correctly parses url path containing whitespace characters - test case failing prior to fix
1 parent 61f27a9 commit 4301610

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

faup/src/grammar.pest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ encoded_char = ${ "%" ~ ASCII_DIGIT{2} }
2020

2121
port = ${ ASCII_ALPHANUMERIC{,5} }
2222

23-
path_segment = ${ (encoded_char | (!("?" | "/" | "#" | WHITE_SPACE) ~ ANY))* }
23+
path_segment = ${ (encoded_char | (!("?" | "/" | "#") ~ ANY))* }
2424
path = ${ ("/" ~ path_segment)+ }
2525

2626
query_char = ${ (!("#") ~ ANY) }

faup/src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,4 +1796,27 @@ mod tests {
17961796
Some("family=Mulish:ital,wght@0,200..1000;1,200..1000&display=swap")
17971797
);
17981798
}
1799+
1800+
#[test]
1801+
fn test_path_whitespace_bug() {
1802+
let u = Url::parse("https://service.eloquant.cloud/ca-interview/itw/efm/resource/com.interview.repondant.web.css.IRepondantCSS/respondent-style-CASA %28no logo%29.css?--69.1.5.9&ver=4.0.1.c-20210712").unwrap();
1803+
// Test scheme
1804+
assert_eq!(u.scheme(), "https");
1805+
1806+
// Test host components
1807+
assert_eq!(u.host().to_string(), "service.eloquant.cloud");
1808+
assert_eq!(u.domain(), Some("eloquant.cloud"));
1809+
assert_eq!(u.suffix_str(), Some("cloud"));
1810+
assert_eq!(u.subdomain(), Some("service"));
1811+
1812+
assert_eq!(
1813+
u.path(),
1814+
Some(
1815+
"/ca-interview/itw/efm/resource/com.interview.repondant.web.css.IRepondantCSS/respondent-style-CASA %28no logo%29.css"
1816+
)
1817+
);
1818+
1819+
// Test query parameters
1820+
assert_eq!(u.query(), Some("--69.1.5.9&ver=4.0.1.c-20210712"));
1821+
}
17991822
}

0 commit comments

Comments
 (0)