getPublicUrl method

String getPublicUrl(
  1. Config config, {
  2. bool isServe = false,
})

Implementation

String getPublicUrl(Config config, {bool isServe = false}) {
  final baseUrl = config.baseUrl.endsWith('/')
      ? config.baseUrl.substring(0, config.baseUrl.length - 1)
      : config.baseUrl;

  return getBuildPath(config)
      .replaceFirst(
        config.build.publicDir,
        isServe ? 'http://127.0.0.1:${config.serve.port}' : baseUrl,
      )
      .replaceFirst('index.html', '');
}