@function str-replace($string, $search, $replace: '') {
  $index: str-index($string, $search);

  @if $index {
    $before: str-slice($string, 1, $index - 1);
    $after: str-replace(
      str-slice($string, $index + str-length($search)),
      $search,
      $replace
    );

    @return $before + $replace + $after;
  }

  @return $string;
}
