Canonicalize.Strategies.NoTrailingSlashStrategy.Apply C# (CSharp) Метод

Apply() публичный Метод

Removes any forward slashes (/) from the end of the part segment of the URL.
public Apply ( UriBuilder uri ) : void
uri System.UriBuilder The URL to be canonicalized.
Результат void
        public void Apply(UriBuilder uri)
        {
            uri.Path = uri.Path.TrimEnd('/');
        }

Usage Example

        public void AssertUrlChange(string originalUrl, string expectedCanonicalUrl)
        {
            var uriBuilder = new UriBuilder(originalUrl);

            IUrlStrategy strategy = new NoTrailingSlashStrategy();
            strategy.Apply(uriBuilder);

            Assert.That(uriBuilder.Uri, Is.EqualTo(new Uri(expectedCanonicalUrl)));
        }
NoTrailingSlashStrategy