Skip to content

Commit d2feb29

Browse files
committed
Merge in wasm-tests changes
1 parent b0a81d7 commit d2feb29

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

url/src/host.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ impl Host<String> {
139139
}
140140
}
141141

142-
#[cfg(not(target_arch="wasm32"))]
143-
/// convert domain with idna
142+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
143+
/// Convert IDN domain to ASCII form with [idna]
144144
fn domain_to_ascii(domain: &str) -> Result<String, ParseError> {
145145
idna::domain_to_ascii(domain).map_err(Into::into)
146146
}
147147

148-
#[cfg(target_arch="wasm32")]
149-
/// convert domain with idna
148+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
149+
/// Convert IDN domain to ASCII form with [web_sys::Url]
150150
fn domain_to_ascii(domain: &str) -> Result<String, ParseError> {
151151
// Url throws an error on empty hostnames
152152
if domain.is_empty() {
@@ -156,9 +156,8 @@ impl Host<String> {
156156
if domain.contains(Self::is_invalid_domain_char) {
157157
return Err(ParseError::InvalidDomainCharacter);
158158
}
159-
let u = web_sys::Url::new(&format!("http://{domain}")).map_err(|_| {
160-
ParseError::IdnaError
161-
})?;
159+
let u =
160+
web_sys::Url::new(&format!("http://{domain}")).map_err(|_| ParseError::IdnaError)?;
162161
Ok(u.host())
163162
}
164163

url/src/origin.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,15 @@ impl Origin {
8585
}
8686
}
8787

88-
#[cfg(not(target_arch = "wasm32"))]
89-
// FIXME: "There used to also be a Unicode serialization of an origin. However, it was never widely adopted."
90-
/// <https://html.spec.whatwg.org/multipage/#unicode-serialisation-of-an-origin>
88+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
89+
#[deprecated]
90+
/// [The Unicode serialization of an origin][0].
91+
///
92+
/// This [has been removed from the standard][1] because it was never widely
93+
/// adopted, and was difficult to use.
94+
///
95+
/// [0]: https://html.spec.whatwg.org/multipage/#unicode-serialisation-of-an-origin
96+
/// [1]: https://github.com/whatwg/html/pull/2689
9197
pub fn unicode_serialization(&self) -> String {
9298
match *self {
9399
Origin::Opaque(_) => "null".to_owned(),

url/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ simple_enum_error! {
8787
Overflow => "URLs more than 4 GB are not supported",
8888
}
8989

90-
#[cfg(not(target_arch = "wasm32"))]
90+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
9191
impl From<::idna::Errors> for ParseError {
9292
fn from(_: ::idna::Errors) -> ParseError {
9393
ParseError::IdnaError

url/src/quirks.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ pub fn domain_to_ascii(domain: &str) -> String {
6565
}
6666
}
6767

68-
#[cfg(not(target_arch = "wasm32"))]
69-
/// https://url.spec.whatwg.org/#dom-url-domaintounicode
68+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
69+
/// <https://url.spec.whatwg.org/#dom-url-domaintounicode>
70+
///
71+
/// This feature is not available on `wasm32-unknown-unknown` targets.
7072
pub fn domain_to_unicode(domain: &str) -> String {
7173
match Host::parse(domain) {
7274
Ok(Host::Domain(ref domain)) => {

url/tests/unit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ fn test_set_href() {
773773
#[test]
774774
fn test_domain_encoding_quirks() {
775775
use url::quirks::domain_to_ascii;
776-
#[cfg(not(target_arch = "wasm32"))]
776+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
777777
use url::quirks::domain_to_unicode;
778778

779779
let data = [
@@ -785,7 +785,7 @@ fn test_domain_encoding_quirks() {
785785

786786
for url in &data {
787787
assert_eq!(domain_to_ascii(url.0), url.1);
788-
#[cfg(not(target_arch = "wasm32"))]
788+
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
789789
assert_eq!(domain_to_unicode(url.0), url.2);
790790
}
791791
}

0 commit comments

Comments
 (0)