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

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

Adds a forward slash (/) to the end of the part segment of the URL, if not already present. No slash is added if the URL contains a period (.) indicating a file extension.
public Apply ( UriBuilder uri ) : void
uri System.UriBuilder The URL to be canonicalized.
Результат void
        public void Apply(UriBuilder uri)
        {
            if (!uri.Path.EndsWith("/") && !uri.Path.Contains("."))
            {
                uri.Path += '/';
            }
        }

Usage Example

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

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

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