// ----
// Sass (v3.3.14)
// Compass (v1.0.1)
// ----

////
// I have written a lot of different `str-replace` Sass functions over
// the months yet none of my tries were succeeding in making the new substring
// able to contain the one to replace (e.g. `str-replace($str, "a", "ab")`).
// Thanks to Valérian Galliat (@valeriangalliat), I finally managed to build
// a bulletproof `str-replace` Sass function that allows new string to contain
// the old one.
////

/// Replace `$search` with `$replace` in `$string`
/// @author Hugo Giraudel
/// @param {String} $string - Initial string
/// @param {String} $search - Substring to replace
/// @param {String} $replace ("") - New value
/// @return {String} - Updated string
@function str-replace($string, $search, $replace: "") {
	$index: str-index($string, $search);

	@if $index {
		@return str-slice($string, 1, $index - 1) + $replace +
			str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
	}

	@return $string;
}
