Skip to content

Commit

Permalink
Rename extension methods back
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeegaan committed Nov 13, 2024
1 parent 578f19d commit b9b7cb6
Show file tree
Hide file tree
Showing 30 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/Umbraco.Cms.Api.Common/OpenApi/SchemaIdHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private string SanitizedTypeName(Type t) => t.Name
// first grab the "non-generic" part of any generic type name (i.e. "PagedViewModel`1" becomes "PagedViewModel")
.Split('`').First()
// then remove the "ViewModel" postfix from type names
.TrimEndExact("ViewModel");
.TrimEnd("ViewModel");

private string HandleGenerics(string name, Type type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private IPublishedMediaCache GetRequiredPublishedMediaCache()
return null;
}

var childrenOf = fetch.TrimStartExact(childrenOfParameter);
var childrenOf = fetch.TrimStart(childrenOfParameter);
if (childrenOf.IsNullOrWhiteSpace())
{
// this mirrors the current behavior of the Content Delivery API :-)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public RequestRedirectService(
}

// important: redirect URLs are always tracked without trailing slashes
IRedirectUrl? redirectUrl = _redirectUrlService.GetMostRecentRedirectUrl(requestedPath.TrimEndExact("/"), culture);
IRedirectUrl? redirectUrl = _redirectUrlService.GetMostRecentRedirectUrl(requestedPath.TrimEnd("/"), culture);
IPublishedContent? content = redirectUrl != null
? _apiPublishedContentCache.GetById(redirectUrl.ContentKey)
: null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Task<PagedViewModel<IndexResponseModel>> All(
{
IndexResponseModel[] indexes = _examineManager.Indexes
.Select(_indexPresentationFactory.Create)
.OrderBy(indexModel => indexModel.Name.TrimEndExact("Indexer")).ToArray();
.OrderBy(indexModel => indexModel.Name.TrimEnd("Indexer")).ToArray();

var viewModel = new PagedViewModel<IndexResponseModel> { Items = indexes.Skip(skip).Take(take), Total = indexes.Length };
return Task.FromResult(viewModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<ActionResult<PagedViewModel<SearcherResponse>>> All(
var searchers = new List<SearcherResponse>(
_examineManager.RegisteredSearchers.Select(searcher => new SearcherResponse { Name = searcher.Name })
.OrderBy(x =>
x.Name.TrimEndExact("Searcher"))); // order by name , but strip the "Searcher" from the end if it exists
x.Name.TrimEnd("Searcher"))); // order by name , but strip the "Searcher" from the end if it exists
var viewModel = new PagedViewModel<SearcherResponse>
{
Items = searchers.Skip(skip).Take(take),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<title>Website is Under Maintainance</title>

<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStartExact("~") , "website", "/nonodes.css")" />
<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStart("~") , "website", "/nonodes.css")" />
<style type="text/css">
body {
color:initial;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<title>Umbraco: No Published Content</title>

<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStartExact("~") , "website", "/nonodes.css")" />
<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStart("~") , "website", "/nonodes.css")" />
</head>
<body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<title>Page Not Found</title>

<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStartExact("~") , "website", "/nonodes.css")" />
<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStart("~") , "website", "/nonodes.css")" />
<style type="text/css">
body {
color:initial;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal static string GetModelsDirectory(string root, string config, bool accep

if (config.StartsWith("~/"))
{
var dir = Path.Combine(root, config.TrimStartExact("~/"));
var dir = Path.Combine(root, config.TrimStart("~/"));

// sanitize - GetFullPath will take care of any relative
// segments in path, eg '../../foo.tmp' - it may throw a SecurityException
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Core/DeliveryApi/ApiContentRouteBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ApiContentRouteBuilder(

if (_globalSettings.HideTopLevelNodeFromPath == false)
{
contentPath = contentPath.TrimStartExact(rootPath.EnsureStartsWith("/")).EnsureStartsWith("/");
contentPath = contentPath.TrimStart(rootPath.EnsureStartsWith("/")).EnsureStartsWith("/");
}

return new ApiContentRoute(contentPath, new ApiContentStartItem(root.Key, rootPath));
Expand Down
10 changes: 5 additions & 5 deletions src/Umbraco.Core/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,14 @@ public static bool IsVowel(this char c)
/// <param name="value">The value.</param>
/// <param name="forRemoving">For removing.</param>
/// <returns></returns>
public static string TrimExact(this string value, string forRemoving)
public static string Trim(this string value, string forRemoving)
{
if (string.IsNullOrEmpty(value))
{
return value;
}

return value.TrimEndExact(forRemoving).TrimStartExact(forRemoving);
return value.TrimEnd(forRemoving).TrimStart(forRemoving);
}

public static string EncodeJsString(this string s)
Expand Down Expand Up @@ -343,7 +343,7 @@ public static string EncodeJsString(this string s)
return sb.ToString();
}

public static string TrimEndExact(this string value, string forRemoving)
public static string TrimEnd(this string value, string forRemoving)
{
if (string.IsNullOrEmpty(value))
{
Expand All @@ -363,7 +363,7 @@ public static string TrimEndExact(this string value, string forRemoving)
return value;
}

public static string TrimStartExact(this string value, string forRemoving)
public static string TrimStart(this string value, string forRemoving)
{
if (string.IsNullOrEmpty(value))
{
Expand All @@ -390,7 +390,7 @@ public static string EnsureStartsWith(this string input, string toStartWith)
return input;
}

return toStartWith + input.TrimStartExact(toStartWith);
return toStartWith + input.TrimStart(toStartWith);
}

public static string EnsureStartsWith(this string input, char value) =>
Expand Down
12 changes: 6 additions & 6 deletions src/Umbraco.Core/Models/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,19 @@ public override bool IsPropertyDirty(string propertyName)
// Special check here since we want to check if the request is for changed cultures
if (propertyName.StartsWith(ChangeTrackingPrefix.PublishedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.PublishedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.PublishedCulture);
return _currentPublishCultureChanges.addedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.UnpublishedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.UnpublishedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UnpublishedCulture);
return _currentPublishCultureChanges.removedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.ChangedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.ChangedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.ChangedCulture);
return _currentPublishCultureChanges.updatedCultures?.Contains(culture) ?? false;
}

Expand All @@ -379,19 +379,19 @@ public override bool WasPropertyDirty(string propertyName)
// Special check here since we want to check if the request is for changed cultures
if (propertyName.StartsWith(ChangeTrackingPrefix.PublishedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.PublishedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.PublishedCulture);
return _previousPublishCultureChanges.addedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.UnpublishedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.UnpublishedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UnpublishedCulture);
return _previousPublishCultureChanges.removedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.ChangedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.ChangedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.ChangedCulture);
return _previousPublishCultureChanges.updatedCultures?.Contains(culture) ?? false;
}

Expand Down
12 changes: 6 additions & 6 deletions src/Umbraco.Core/Models/ContentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -578,19 +578,19 @@ public override bool IsPropertyDirty(string propertyName)
// Special check here since we want to check if the request is for changed cultures
if (propertyName.StartsWith(ChangeTrackingPrefix.AddedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.AddedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.AddedCulture);
return _currentCultureChanges.addedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.RemovedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.RemovedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.RemovedCulture);
return _currentCultureChanges.removedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.UpdatedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.UpdatedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UpdatedCulture);
return _currentCultureChanges.updatedCultures?.Contains(culture) ?? false;
}

Expand All @@ -609,19 +609,19 @@ public override bool WasPropertyDirty(string propertyName)
// Special check here since we want to check if the request is for changed cultures
if (propertyName.StartsWith(ChangeTrackingPrefix.AddedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.AddedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.AddedCulture);
return _previousCultureChanges.addedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.RemovedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.RemovedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.RemovedCulture);
return _previousCultureChanges.removedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.UpdatedCulture))
{
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.UpdatedCulture);
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UpdatedCulture);
return _previousCultureChanges.updatedCultures?.Contains(culture) ?? false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Core/Routing/UmbracoRequestPaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public UmbracoRequestPaths(IOptions<GlobalSettings> globalSettings, IHostingEnvi
_appPath = hostingEnvironment.ApplicationVirtualPath;

_backOfficePath = globalSettings.Value.GetBackOfficePath(hostingEnvironment)
.EnsureStartsWith('/').TrimStartExact(_appPath).EnsureStartsWith('/');
.EnsureStartsWith('/').TrimStart(_appPath).EnsureStartsWith('/');

string mvcArea = globalSettings.Value.GetUmbracoMvcArea(hostingEnvironment);

Expand Down Expand Up @@ -73,7 +73,7 @@ public UmbracoRequestPaths(IOptions<GlobalSettings> globalSettings, IHostingEnvi
/// </remarks>
public bool IsBackOfficeRequest(string absPath)
{
string urlPath = absPath.TrimStartExact(_appPath).EnsureStartsWith('/');
string urlPath = absPath.TrimStart(_appPath).EnsureStartsWith('/');

// check if this is in the umbraco back office
if (!urlPath.InvariantStartsWith(_backOfficePath))
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private bool BuildQuery(StringBuilder sb, string query, string? searchFrom, List
for (var index = 0; index < querywords.Length; index++)
{
queryWordsReplaced[index] =
querywords[index].Replace("\\-", " ").Replace("_", " ").TrimExact(" ");
querywords[index].Replace("\\-", " ").Replace("_", " ").Trim(" ");
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Examine.Lucene/LuceneIndexDiagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public LuceneIndexDiagnostics(
{
var rootDir = _hostingEnvironment.ApplicationPhysicalPath;
d["LuceneIndexFolder"] = fsDir.Directory.ToString().ToLowerInvariant()
.TrimStartExact(rootDir.ToLowerInvariant()).Replace("\\", " /").EnsureStartsWith('/');
.TrimStart(rootDir.ToLowerInvariant()).Replace("\\", " /").EnsureStartsWith('/');
}

if (_indexOptions != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private static void SanitizeAttributes(Dictionary<string, object> attributes)

foreach (KeyValuePair<string, object> dataAttribute in dataAttributes)
{
var actualKey = dataAttribute.Key.TrimStartExact("data-");
var actualKey = dataAttribute.Key.TrimStart("data-");
attributes.TryAdd(actualKey, dataAttribute.Value);

attributes.Remove(dataAttribute.Key);
Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Infrastructure/Install/FilePermissionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private bool EnsureDirectories(string[] dirs, out IEnumerable<string> errors, bo

temp ??= new List<string>();

temp.Add(dir.TrimStartExact(_basePath));
temp.Add(dir.TrimStart(_basePath));
success = false;
}

Expand All @@ -115,7 +115,7 @@ private bool EnsureFiles(string[] files, out IEnumerable<string> errors)

temp ??= new List<string>();

temp.Add(file.TrimStartExact(_basePath));
temp.Add(file.TrimStart(_basePath));
success = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static LoggerConfiguration MinimalConfiguration(

//Set this environment variable - so that it can be used in external config file
//add key="serilog:write-to:RollingFile.pathFormat" value="%BASEDIR%\logs\log.txt" />
Environment.SetEnvironmentVariable("BASEDIR", hostEnvironment.MapPathContentRoot("/").TrimEndExact("\\"), EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("BASEDIR", hostEnvironment.MapPathContentRoot("/").TrimEnd("\\"), EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("UMBLOGDIR", loggingConfiguration.LogDirectory, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("MACHINENAME", Environment.MachineName, EnvironmentVariableTarget.Process);

Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public static Sql<ISqlContext> WhereAny(this Sql<ISqlContext> sql, params Func<S

var temp = new Sql<ISqlContext>(sql.SqlContext);
temp = predicates[i](temp);
wsql.Append(temp.SQL.TrimStartExact("WHERE "), temp.Arguments);
wsql.Append(temp.SQL.TrimStart("WHERE "), temp.Arguments);
}
wsql.Append(")");

Expand Down Expand Up @@ -615,7 +615,7 @@ public static Sql<ISqlContext> On(this Sql<ISqlContext>.SqlJoinClause<ISqlContex
{
var sql = new Sql<ISqlContext>(sqlJoin.SqlContext);
sql = on(sql);
var text = sql.SQL.Trim().TrimStartExact("WHERE").Trim();
var text = sql.SQL.Trim().TrimStart("WHERE").Trim();
return sqlJoin.On(text, sql.Arguments);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ private Sql<ISqlContext> ApplyFilter(Sql<ISqlContext> sql, Sql<ISqlContext>? fil
var args = filterSql.Arguments;
var sqlFilter = hasWhereClause
? filterSql.SQL
: " WHERE " + filterSql.SQL.TrimStartExact("AND ");
: " WHERE " + filterSql.SQL.TrimStart("AND ");

sql.Append(SqlContext.Sql(sqlFilter, args));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public virtual string Format(IEnumerable<ColumnDefinition> columns)
sb.Append(Format(column) + ",\n");
}

return sb.ToString().TrimEndExact(",\n");
return sb.ToString().TrimEnd(",\n");
}

public virtual string Format(ColumnDefinition column) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public static IApplicationBuilder UseUmbracoMediaFileProvider(this IApplicationB
public static IApplicationBuilder UseUmbracoBackOfficeRewrites(this IApplicationBuilder builder)
{
IBackOfficePathGenerator backOfficePathGenerator = builder.ApplicationServices.GetRequiredService<IBackOfficePathGenerator>();
var backOfficeAssetsPath = backOfficePathGenerator.BackOfficeAssetsPath.TrimStartExact("/").EnsureEndsWith("/");
var backOfficeAssetsPath = backOfficePathGenerator.BackOfficeAssetsPath.TrimStart("/").EnsureEndsWith("/");

builder.UseRewriter(new RewriteOptions()
// The destination needs to be hardcoded to "/umbraco/backoffice" because this is where they are located in the Umbraco.Cms.StaticAssets RCL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static class LinkGeneratorExtensions
" or the result ");
}

return linkGenerator.GetUmbracoApiService<T>(method.Name)?.TrimEndExact(method.Name);
return linkGenerator.GetUmbracoApiService<T>(method.Name)?.TrimEnd(method.Name);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Web.Common/Extensions/UrlHelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public static class UrlHelperExtensions
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
string actionName)
where T : UmbracoApiController =>
url.GetUmbracoApiService<T>(umbracoApiControllerTypeCollection, actionName)?.TrimEndExact(actionName);
url.GetUmbracoApiService<T>(umbracoApiControllerTypeCollection, actionName)?.TrimEnd(actionName);

[Obsolete("This will be removed in Umbraco 15.")]
public static string? GetUmbracoApiServiceBaseUrl<T>(
Expand All @@ -213,7 +213,7 @@ public static class UrlHelperExtensions
" or the result ");
}

return url.GetUmbracoApiService<T>(umbracoApiControllerTypeCollection, method.Name)?.TrimEndExact(method.Name);
return url.GetUmbracoApiService<T>(umbracoApiControllerTypeCollection, method.Name)?.TrimEnd(method.Name);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static ILocalizedTextService GetLocalizedTextService(IServiceProvider fa
uiProject.Create();
}

var mainLangFolder = new DirectoryInfo(Path.Combine(uiProject.FullName, Constants.System.DefaultUmbracoPath.TrimStartExact("~/"), "config", "lang"));
var mainLangFolder = new DirectoryInfo(Path.Combine(uiProject.FullName, Constants.System.DefaultUmbracoPath.TrimStart("~/"), "config", "lang"));

return new LocalizedTextServiceFileSources(
loggerFactory.CreateLogger<LocalizedTextServiceFileSources>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected async Task AuthenticateClientAsync(HttpClient client, string username,

var codeVerifier = "12345"; // Just a dummy value we use in tests
var codeChallange = Convert.ToBase64String(SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(codeVerifier)))
.TrimEndExact("=");
.TrimEnd("=");

var authorizationUrl = GetManagementApiUrl<BackOfficeController>(x => x.Authorize(CancellationToken.None)) +
$"?client_id={backofficeOpenIddictApplicationDescriptor.ClientId}&response_type=code&redirect_uri={WebUtility.UrlEncode(backofficeOpenIddictApplicationDescriptor.RedirectUris.FirstOrDefault()?.AbsoluteUri)}&code_challenge_method=S256&code_challenge={codeChallange}";
Expand Down
Loading

0 comments on commit b9b7cb6

Please sign in to comment.