extractPathname function Null safety

String extractPathname(
  1. String url
)

Extracts the pathname part of a full url.

Example: for the url http://example.com/foo, the extracted pathname will be /foo.

Implementation

String extractPathname(String url) {
  _urlParsingNode.href = url; // ignore: unsafe_html, node is never exposed to the user
  final String pathname = _urlParsingNode.pathname ?? '';
  return (pathname.isEmpty || pathname[0] == '/') ? pathname : '/$pathname';
}