From de9d82777f5a5b569071197b2c0c6b4337db9bb0 Mon Sep 17 00:00:00 2001 From: Elitsa Marinovska Date: Tue, 17 Mar 2020 10:21:43 +0100 Subject: [PATCH] Introducing ReplaceFirst() as string extension instead of using the CDF one --- src/Umbraco.Core/StringExtensions.cs | 15 +++++++++++++++ src/Umbraco.Web/Editors/CodeFileController.cs | 1 - 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs index d61c0a87ca..9152d686a2 100644 --- a/src/Umbraco.Core/StringExtensions.cs +++ b/src/Umbraco.Core/StringExtensions.cs @@ -938,7 +938,22 @@ namespace Umbraco.Core return text; } + /// + /// Returns a new string in which only the first occurrence of a specified string is replaced by a specified replacement string. + /// + /// The string to filter. + /// The string to replace. + /// The replacement string. + /// The filtered string. + public static string ReplaceFirst(this string text, string search, string replace) + { + var pos = text.IndexOf(search); + if (pos < 0) + return text; + + return text.Substring(0, pos) + replace + text.Substring(pos + search.Length); + } diff --git a/src/Umbraco.Web/Editors/CodeFileController.cs b/src/Umbraco.Web/Editors/CodeFileController.cs index 325b39e4f2..2de3283b95 100644 --- a/src/Umbraco.Web/Editors/CodeFileController.cs +++ b/src/Umbraco.Web/Editors/CodeFileController.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; -using ClientDependency.Core; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Configuration;