uri property

Uri get uri

Current url transformation to URI.

In tryParse failures FormatException will be throw.

Implementation

Uri get uri {
  final uri = Uri.parse(host); //!will be throw.
  final checkPath = uri.path.replaceFirst('/', '');

  if (uri.host.isEmpty || checkPath.isNotEmpty) {
    throw const FormatException('Url provide is not a valid URL');
  }

  var modifyPath = _buildPath();
  pathModification.forEach(
    (key, value) => modifyPath = modifyPath.replaceFirst(key, value),
  );

  final completeUri = Uri(
    host: uri.host,
    port: uri.port,
    path: modifyPath,
    scheme: uri.scheme,
  );

  observer.onUriCreation(
    path,
    pathModification,
    completeUri,
    datasourceName: runtimeType.toString(),
  );

  return completeUri;
}