@@ -252,70 +252,73 @@ bool uri::has_scheme() const noexcept {
252
252
}
253
253
254
254
uri::string_view uri::scheme () const noexcept {
255
- assert ( has_scheme ());
256
- return to_string_view (uri_, *uri_parts_-> scheme ) ;
255
+ return has_scheme () ? to_string_view (uri_, *uri_parts_-> scheme )
256
+ : string_view{} ;
257
257
}
258
258
259
259
bool uri::has_user_info () const noexcept {
260
260
return static_cast <bool >(uri_parts_->hier_part .user_info );
261
261
}
262
262
263
263
uri::string_view uri::user_info () const noexcept {
264
- assert (has_user_info ());
265
- return to_string_view (uri_, *uri_parts_->hier_part .user_info );
264
+ return has_user_info ()
265
+ ? to_string_view (uri_, *uri_parts_->hier_part .user_info )
266
+ : string_view{};
266
267
}
267
268
268
269
bool uri::has_host () const noexcept {
269
270
return static_cast <bool >(uri_parts_->hier_part .host );
270
271
}
271
272
272
273
uri::string_view uri::host () const noexcept {
273
- assert ( has_host ());
274
- return to_string_view (uri_, *uri_parts_-> hier_part . host ) ;
274
+ return has_host () ? to_string_view (uri_, *uri_parts_-> hier_part . host )
275
+ : string_view{} ;
275
276
}
276
277
277
278
bool uri::has_port () const noexcept {
278
279
return static_cast <bool >(uri_parts_->hier_part .port );
279
280
}
280
281
281
282
uri::string_view uri::port () const noexcept {
282
- assert ( has_port ());
283
- return to_string_view (uri_, *uri_parts_-> hier_part . port ) ;
283
+ return has_port () ? to_string_view (uri_, *uri_parts_-> hier_part . port )
284
+ : string_view{} ;
284
285
}
285
286
286
287
bool uri::has_path () const noexcept {
287
288
return static_cast <bool >(uri_parts_->hier_part .path );
288
289
}
289
290
290
291
uri::string_view uri::path () const noexcept {
291
- assert ( has_path ());
292
- return to_string_view (uri_, *uri_parts_-> hier_part . path ) ;
292
+ return has_path () ? to_string_view (uri_, *uri_parts_-> hier_part . path )
293
+ : string_view{} ;
293
294
}
294
295
295
296
bool uri::has_query () const noexcept {
296
297
return static_cast <bool >(uri_parts_->query );
297
298
}
298
299
299
300
uri::string_view uri::query () const noexcept {
300
- assert (has_query ());
301
- return to_string_view (uri_, *uri_parts_->query );
301
+ return has_query () ? to_string_view (uri_, *uri_parts_->query ) : string_view{};
302
302
}
303
303
304
304
bool uri::has_fragment () const noexcept {
305
305
return static_cast <bool >(uri_parts_->fragment );
306
306
}
307
307
308
308
uri::string_view uri::fragment () const noexcept {
309
- assert ( has_fragment ());
310
- return to_string_view (uri_, *uri_parts_-> fragment ) ;
309
+ return has_fragment () ? to_string_view (uri_, *uri_parts_-> fragment )
310
+ : string_view{} ;
311
311
}
312
312
313
313
bool uri::has_authority () const noexcept {
314
314
return has_host ();
315
315
}
316
316
317
317
uri::string_view uri::authority () const noexcept {
318
- assert (has_host ());
318
+ if (!has_host ()) {
319
+ return string_view{};
320
+ }
321
+
319
322
auto host = this ->host ();
320
323
321
324
auto user_info = string_view{};
0 commit comments