Skip to content

Commit

Permalink
fix: sass warnings when using deprecated str- mixins (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinderoubaix authored Feb 18, 2025
1 parent 5d373b5 commit 9c4ba08
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions core-bootstrap/src/scss/_functions.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
@use 'sass:string';

/**
* Utility function to replace a substring as Sass doesn't provide the built-in method to do it
*/
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);
$index: string.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.slice($string, 1, $index - 1) + $replace + str-replace(string.slice($string, $index + string.length($search)), $search, $replace);
}

@return $string;
Expand All @@ -19,11 +21,11 @@ $escaped-characters: (('<', '%3c'), ('>', '%3e'), ('#', '%23'), ('(', '%28'), ('
* ref: https://github.com/twbs/bootstrap/blob/cacbdc680ecdfee5f0c7fbb876ad15188eaf697d/scss/_functions.scss#L131
*/
@function escape-svg($string) {
@if str-index($string, 'data:image/svg+xml') {
@if string.index($string, 'data:image/svg+xml') {
@each $char, $encoded in $escaped-characters {
// Do not escape the url brackets
@if str-index($string, 'url(') == 1 {
$string: url('#{str-replace(str-slice($string, 6, -3), $char, $encoded)}');
@if string.index($string, 'url(') == 1 {
$string: url('#{str-replace(string.slice($string, 6, -3), $char, $encoded)}');
} @else {
$string: str-replace($string, $char, $encoded);
}
Expand Down

0 comments on commit 9c4ba08

Please sign in to comment.