C# Get origin from url

Date: 2021-11-08
using System;
using System.Text.RegularExpressions;

namespace Domain.Helpers
{
    public class StringHelper
    {
        private static Regex reUrlOrigin = new Regex(@"(.+://[^/]+)");

        public static string GetOriginFromUrl(string url)
        {
            var match = reUrlOrigin.Match(url);
            if (match.Success)
            {
                return match.Groups[1].Value;
            }
            return null;
        }
    }
}
55380cookie-checkC# Get origin from url