Exemplo n.º 1
0
        public void ParseSimpleLinkHeader()
        {
            var isValid = WebLink.TryParse("<http://example.org/foo.json>", out var link);

            Assert.True(isValid);
            Assert.Equal("http://example.org/foo.json", link.LinkValue);
        }
Exemplo n.º 2
0
        public void ItCanParseAQuotedMediaType()
        {
            var isValid = WebLink.TryParse("<http://example.org/foo.json>;type=\"application/ld+json\"", out var link);

            Assert.True(isValid);
            Assert.Equal(new[] { "application/ld+json" }, link.MediaTypes);
        }
Exemplo n.º 3
0
        public void ItCanParseMultipleValuesFromTheRelField()
        {
            var isValid = WebLink.TryParse("<http://example.org/foo.json>;rel=\"rel1 rel2\"", out var link);

            Assert.True(isValid);
            Assert.Equal(new[] { "rel1", "rel2" }, link.RelationTypes);
        }
Exemplo n.º 4
0
 private static IEnumerable <WebLink> ParseLinkHeaders(IEnumerable <string> linkHeaderValues)
 {
     foreach (var linkHeaderValue in linkHeaderValues)
     {
         if (WebLink.TryParse(linkHeaderValue, out var link))
         {
             yield return(link);
         }
     }
 }
Exemplo n.º 5
0
        public void ItCanParseMultipleFields()
        {
            var isValid = WebLink.TryParse("<http://example.org/foo.json>;type=\"application/ld+json\";rel=alternate",
                                           out var link);

            Assert.True(isValid);
            Assert.Equal(new[] { "application/ld+json" }, link.MediaTypes);
            Assert.Equal(new string[] { "alternate" }, link.RelationTypes);
            Assert.Equal("http://example.org/foo.json", link.LinkValue);
        }