6
6
// option. This file may not be copied, modified, or distributed
7
7
// except according to those terms.
8
8
9
- //! Getters and setters for URL components implemented per https://url.spec.whatwg.org/#api
9
+ //! Getters and setters for URL components implemented per < https://url.spec.whatwg.org/#api>
10
10
//!
11
11
//! Unless you need to be interoperable with web browsers,
12
12
//! you probably want to use `Url` method instead.
@@ -57,15 +57,15 @@ pub fn internal_components(url: &Url) -> InternalComponents {
57
57
}
58
58
}
59
59
60
- /// https://url.spec.whatwg.org/#dom-url-domaintoascii
60
+ /// < https://url.spec.whatwg.org/#dom-url-domaintoascii>
61
61
pub fn domain_to_ascii ( domain : & str ) -> String {
62
62
match Host :: parse ( domain) {
63
63
Ok ( Host :: Domain ( domain) ) => domain,
64
64
_ => String :: new ( ) ,
65
65
}
66
66
}
67
67
68
- /// https://url.spec.whatwg.org/#dom-url-domaintounicode
68
+ /// < https://url.spec.whatwg.org/#dom-url-domaintounicode>
69
69
pub fn domain_to_unicode ( domain : & str ) -> String {
70
70
match Host :: parse ( domain) {
71
71
Ok ( Host :: Domain ( ref domain) ) => {
@@ -76,29 +76,29 @@ pub fn domain_to_unicode(domain: &str) -> String {
76
76
}
77
77
}
78
78
79
- /// Getter for https://url.spec.whatwg.org/#dom-url-href
79
+ /// Getter for < https://url.spec.whatwg.org/#dom-url-href>
80
80
pub fn href ( url : & Url ) -> & str {
81
81
url. as_str ( )
82
82
}
83
83
84
- /// Setter for https://url.spec.whatwg.org/#dom-url-href
84
+ /// Setter for < https://url.spec.whatwg.org/#dom-url-href>
85
85
pub fn set_href ( url : & mut Url , value : & str ) -> Result < ( ) , ParseError > {
86
86
* url = Url :: parse ( value) ?;
87
87
Ok ( ( ) )
88
88
}
89
89
90
- /// Getter for https://url.spec.whatwg.org/#dom-url-origin
90
+ /// Getter for < https://url.spec.whatwg.org/#dom-url-origin>
91
91
pub fn origin ( url : & Url ) -> String {
92
92
url. origin ( ) . ascii_serialization ( )
93
93
}
94
94
95
- /// Getter for https://url.spec.whatwg.org/#dom-url-protocol
95
+ /// Getter for < https://url.spec.whatwg.org/#dom-url-protocol>
96
96
#[ inline]
97
97
pub fn protocol ( url : & Url ) -> & str {
98
98
& url. as_str ( ) [ ..url. scheme ( ) . len ( ) + ":" . len ( ) ]
99
99
}
100
100
101
- /// Setter for https://url.spec.whatwg.org/#dom-url-protocol
101
+ /// Setter for < https://url.spec.whatwg.org/#dom-url-protocol>
102
102
#[ allow( clippy:: result_unit_err) ]
103
103
pub fn set_protocol ( url : & mut Url , mut new_protocol : & str ) -> Result < ( ) , ( ) > {
104
104
// The scheme state in the spec ignores everything after the first `:`,
@@ -109,25 +109,25 @@ pub fn set_protocol(url: &mut Url, mut new_protocol: &str) -> Result<(), ()> {
109
109
url. set_scheme ( new_protocol)
110
110
}
111
111
112
- /// Getter for https://url.spec.whatwg.org/#dom-url-username
112
+ /// Getter for < https://url.spec.whatwg.org/#dom-url-username>
113
113
#[ inline]
114
114
pub fn username ( url : & Url ) -> & str {
115
115
url. username ( )
116
116
}
117
117
118
- /// Setter for https://url.spec.whatwg.org/#dom-url-username
118
+ /// Setter for < https://url.spec.whatwg.org/#dom-url-username>
119
119
#[ allow( clippy:: result_unit_err) ]
120
120
pub fn set_username ( url : & mut Url , new_username : & str ) -> Result < ( ) , ( ) > {
121
121
url. set_username ( new_username)
122
122
}
123
123
124
- /// Getter for https://url.spec.whatwg.org/#dom-url-password
124
+ /// Getter for < https://url.spec.whatwg.org/#dom-url-password>
125
125
#[ inline]
126
126
pub fn password ( url : & Url ) -> & str {
127
127
url. password ( ) . unwrap_or ( "" )
128
128
}
129
129
130
- /// Setter for https://url.spec.whatwg.org/#dom-url-password
130
+ /// Setter for < https://url.spec.whatwg.org/#dom-url-password>
131
131
#[ allow( clippy:: result_unit_err) ]
132
132
pub fn set_password ( url : & mut Url , new_password : & str ) -> Result < ( ) , ( ) > {
133
133
url. set_password ( if new_password. is_empty ( ) {
@@ -137,13 +137,13 @@ pub fn set_password(url: &mut Url, new_password: &str) -> Result<(), ()> {
137
137
} )
138
138
}
139
139
140
- /// Getter for https://url.spec.whatwg.org/#dom-url-host
140
+ /// Getter for < https://url.spec.whatwg.org/#dom-url-host>
141
141
#[ inline]
142
142
pub fn host ( url : & Url ) -> & str {
143
143
& url[ Position :: BeforeHost ..Position :: AfterPort ]
144
144
}
145
145
146
- /// Setter for https://url.spec.whatwg.org/#dom-url-host
146
+ /// Setter for < https://url.spec.whatwg.org/#dom-url-host>
147
147
#[ allow( clippy:: result_unit_err) ]
148
148
pub fn set_host ( url : & mut Url , new_host : & str ) -> Result < ( ) , ( ) > {
149
149
// If context object’s url’s cannot-be-a-base-URL flag is set, then return.
@@ -190,13 +190,13 @@ pub fn set_host(url: &mut Url, new_host: &str) -> Result<(), ()> {
190
190
Ok ( ( ) )
191
191
}
192
192
193
- /// Getter for https://url.spec.whatwg.org/#dom-url-hostname
193
+ /// Getter for < https://url.spec.whatwg.org/#dom-url-hostname>
194
194
#[ inline]
195
195
pub fn hostname ( url : & Url ) -> & str {
196
196
url. host_str ( ) . unwrap_or ( "" )
197
197
}
198
198
199
- /// Setter for https://url.spec.whatwg.org/#dom-url-hostname
199
+ /// Setter for < https://url.spec.whatwg.org/#dom-url-hostname>
200
200
#[ allow( clippy:: result_unit_err) ]
201
201
pub fn set_hostname ( url : & mut Url , new_hostname : & str ) -> Result < ( ) , ( ) > {
202
202
if url. cannot_be_a_base ( ) {
@@ -232,13 +232,13 @@ pub fn set_hostname(url: &mut Url, new_hostname: &str) -> Result<(), ()> {
232
232
}
233
233
}
234
234
235
- /// Getter for https://url.spec.whatwg.org/#dom-url-port
235
+ /// Getter for < https://url.spec.whatwg.org/#dom-url-port>
236
236
#[ inline]
237
237
pub fn port ( url : & Url ) -> & str {
238
238
& url[ Position :: BeforePort ..Position :: AfterPort ]
239
239
}
240
240
241
- /// Setter for https://url.spec.whatwg.org/#dom-url-port
241
+ /// Setter for < https://url.spec.whatwg.org/#dom-url-port>
242
242
#[ allow( clippy:: result_unit_err) ]
243
243
pub fn set_port ( url : & mut Url , new_port : & str ) -> Result < ( ) , ( ) > {
244
244
let result;
@@ -262,13 +262,13 @@ pub fn set_port(url: &mut Url, new_port: &str) -> Result<(), ()> {
262
262
}
263
263
}
264
264
265
- /// Getter for https://url.spec.whatwg.org/#dom-url-pathname
265
+ /// Getter for < https://url.spec.whatwg.org/#dom-url-pathname>
266
266
#[ inline]
267
267
pub fn pathname ( url : & Url ) -> & str {
268
268
url. path ( )
269
269
}
270
270
271
- /// Setter for https://url.spec.whatwg.org/#dom-url-pathname
271
+ /// Setter for < https://url.spec.whatwg.org/#dom-url-pathname>
272
272
pub fn set_pathname ( url : & mut Url , new_pathname : & str ) {
273
273
if url. cannot_be_a_base ( ) {
274
274
return ;
@@ -291,12 +291,12 @@ pub fn set_pathname(url: &mut Url, new_pathname: &str) {
291
291
}
292
292
}
293
293
294
- /// Getter for https://url.spec.whatwg.org/#dom-url-search
294
+ /// Getter for < https://url.spec.whatwg.org/#dom-url-search>
295
295
pub fn search ( url : & Url ) -> & str {
296
296
trim ( & url[ Position :: AfterPath ..Position :: AfterQuery ] )
297
297
}
298
298
299
- /// Setter for https://url.spec.whatwg.org/#dom-url-search
299
+ /// Setter for < https://url.spec.whatwg.org/#dom-url-search>
300
300
pub fn set_search ( url : & mut Url , new_search : & str ) {
301
301
url. set_query ( match new_search {
302
302
"" => None ,
@@ -305,12 +305,12 @@ pub fn set_search(url: &mut Url, new_search: &str) {
305
305
} )
306
306
}
307
307
308
- /// Getter for https://url.spec.whatwg.org/#dom-url-hash
308
+ /// Getter for < https://url.spec.whatwg.org/#dom-url-hash>
309
309
pub fn hash ( url : & Url ) -> & str {
310
310
trim ( & url[ Position :: AfterQuery ..] )
311
311
}
312
312
313
- /// Setter for https://url.spec.whatwg.org/#dom-url-hash
313
+ /// Setter for < https://url.spec.whatwg.org/#dom-url-hash>
314
314
pub fn set_hash ( url : & mut Url , new_hash : & str ) {
315
315
url. set_fragment ( match new_hash {
316
316
// If the given value is the empty string,
0 commit comments