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;
  final String pathname = _urlParsingNode.pathname ?? '';
  return (pathname.isEmpty || pathname[0] == '/') ? pathname : '/$pathname';
}