namespace SharedKernel.Storage
{
    public static class FileUtils
    {
        public static string NormalizeExtension(string ext)
        {
            var x = ext.Trim().ToLowerInvariant();

            if (!x.StartsWith('.'))
            {
                x = "." + x;
            }

            if (x == ".jpeg")
            {
                x = ".jpg";
            }

            return x;
        }

        public static bool IsLocalPublicUrl(string src)
        {
            return src.StartsWith("/uploads/", StringComparison.OrdinalIgnoreCase) || src.StartsWith("/editors/", StringComparison.OrdinalIgnoreCase);
        }

        public static bool IsLocalEditorUrl(string src, string baseUrlPrefix)
        {
            return src.StartsWith(baseUrlPrefix, StringComparison.OrdinalIgnoreCase);
        }
    }
}