File: Internal\PathHelpers.cs
Web Access
Project: src\aspnetcore\src\Features\JsonPatch\src\Microsoft.AspNetCore.JsonPatch.csproj (Microsoft.AspNetCore.JsonPatch)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System;
 
namespace Microsoft.AspNetCore.JsonPatch.Internal;
 
internal static class PathHelpers
{
    internal static string NormalizePath(string path)
    {
        // An empty string on its own is valid, and is different from "/".
        // So, we never want to normalize an empty string.
        if (path.Length > 0 && !path.StartsWith("/", StringComparison.Ordinal))
        {
            return $"/{path}";
        }
 
        return path;
    }
}