File tree Expand file tree Collapse file tree 5 files changed +22
-15
lines changed Expand file tree Collapse file tree 5 files changed +22
-15
lines changed Original file line number Diff line number Diff line change @@ -139,14 +139,14 @@ impl Host<String> {
139
139
}
140
140
}
141
141
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]
144
144
fn domain_to_ascii ( domain : & str ) -> Result < String , ParseError > {
145
145
idna:: domain_to_ascii ( domain) . map_err ( Into :: into)
146
146
}
147
147
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]
150
150
fn domain_to_ascii ( domain : & str ) -> Result < String , ParseError > {
151
151
// Url throws an error on empty hostnames
152
152
if domain. is_empty ( ) {
@@ -156,9 +156,8 @@ impl Host<String> {
156
156
if domain. contains ( Self :: is_invalid_domain_char) {
157
157
return Err ( ParseError :: InvalidDomainCharacter ) ;
158
158
}
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 ) ?;
162
161
Ok ( u. host ( ) )
163
162
}
164
163
Original file line number Diff line number Diff line change @@ -85,9 +85,15 @@ impl Origin {
85
85
}
86
86
}
87
87
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
91
97
pub fn unicode_serialization ( & self ) -> String {
92
98
match * self {
93
99
Origin :: Opaque ( _) => "null" . to_owned ( ) ,
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ simple_enum_error! {
87
87
Overflow => "URLs more than 4 GB are not supported" ,
88
88
}
89
89
90
- #[ cfg( not( target_arch = "wasm32" ) ) ]
90
+ #[ cfg( not( all ( target_arch = "wasm32" , target_os = "unknown" ) ) ) ]
91
91
impl From < :: idna:: Errors > for ParseError {
92
92
fn from ( _: :: idna:: Errors ) -> ParseError {
93
93
ParseError :: IdnaError
Original file line number Diff line number Diff line change @@ -65,8 +65,10 @@ pub fn domain_to_ascii(domain: &str) -> String {
65
65
}
66
66
}
67
67
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.
70
72
pub fn domain_to_unicode ( domain : & str ) -> String {
71
73
match Host :: parse ( domain) {
72
74
Ok ( Host :: Domain ( ref domain) ) => {
Original file line number Diff line number Diff line change @@ -772,7 +772,7 @@ fn test_set_href() {
772
772
#[ test]
773
773
fn test_domain_encoding_quirks ( ) {
774
774
use url:: quirks:: domain_to_ascii;
775
- #[ cfg( not( target_arch = "wasm32" ) ) ]
775
+ #[ cfg( not( all ( target_arch = "wasm32" , target_os = "unknown" ) ) ) ]
776
776
use url:: quirks:: domain_to_unicode;
777
777
778
778
let data = [
@@ -784,7 +784,7 @@ fn test_domain_encoding_quirks() {
784
784
785
785
for url in & data {
786
786
assert_eq ! ( domain_to_ascii( url. 0 ) , url. 1 ) ;
787
- #[ cfg( not( target_arch = "wasm32" ) ) ]
787
+ #[ cfg( not( all ( target_arch = "wasm32" , target_os = "unknown" ) ) ) ]
788
788
assert_eq ! ( domain_to_unicode( url. 0 ) , url. 2 ) ;
789
789
}
790
790
}
You can’t perform that action at this time.
0 commit comments