Canonicalize.Strategies.PatternStrategy.Apply C# (CSharp) Method

Apply() public method

Matches the path of the URL against the pattern and assigns the replacement string (with substitutions) if matching.
public Apply ( UriBuilder uri ) : void
uri System.UriBuilder The URL to be canonicalized.
return void
        public void Apply(UriBuilder uri)
        {
            uri.Path = _regex.Replace(uri.Path, _replacement);
        }

Usage Example

コード例 #1
0
        public void AssertUrlChange(string originalUrl, string expectedCanonicalUrl)
        {
            var uriBuilder = new UriBuilder(originalUrl);

            IUrlStrategy strategy = new PatternStrategy(@"^/foo\b", "/bar");
            strategy.Apply(uriBuilder);

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