baseUrl property

  1. @override
String get baseUrl

Base URL.

  • If server-side, it's '/' or a path from <base href="...">
  • If client-side, it's window.location.origin

Implementation

@override
String get baseUrl {
  if (_baseUrl != null) return _baseUrl;

  final href = _baseHref;
  if (Uri.tryParse(href)?.hasScheme ?? false) {
    return href.replaceFirst(RegExp(r'/+$'), '');
  }

  return location.origin + _basePath;
}