build method

String build(
  1. String path
)

Builds a safe url based on your baseUrl.

If path starts with /, it's considered to be relative to the base url. i.e. the path passed as parameter is appended to the baseUrl.

Otherwise, the url is considered to be absolute and it doesn't use the baseUrl to be built.

Urls that are not yet encoded will be encoded.

Implementation

String build(String path) {
  final isRelative = path.startsWith('/');
  final url = isRelative ? '$_baseUrl$path' : path;
  return _shouldEncodeUrl(url) ? Uri.encodeFull(url) : url;
}