trimQuery method

String trimQuery()

Trims URL query characters (after ?).

URLのクエリ文字(?以降)をトリムします。

final url = "https://google.com?q=searchtext";
final trimed = url.trimQuery(); // "https://google.com"

Implementation

String trimQuery() {
  if (!contains("?")) {
    return this;
  }
  return split("?").first;
}