Garden 🌻

String::strip_suffix

Returns this string without the suffix specified. If this string does not end with the suffix, return the string unchanged.

"foo".strip_suffix("o") //-> "fo"
"bar".strip_suffix("o") //-> "bar"
Source Codepublic method strip_suffix(this: String, suffix: String): String {
  if this.ends_with(suffix) {
    return this.substring(0, this.len() - suffix.len())
  }

  this
}