getUrlHostFromWebUrl static method

String getUrlHostFromWebUrl(
  1. String webUrl
)

获取指定web地址的 url host

例如:https://www.baidu.com/?a=1&b=2 返回:https://www.baidu.com

Implementation

static String getUrlHostFromWebUrl(String webUrl) {
  var paramStartIndex = webUrl.indexOf('?');
  if (paramStartIndex == -1) {
    return webUrl;
  }

  var str = webUrl.substring(0, paramStartIndex);
  return str;
}