<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Thinktecture.IdentityServer
{
    public class AbsoluteUriAttribute : ValidationAttribute
    {
        public AbsoluteUriAttribute()
        {
            ErrorMessage = "{0} must be an absolute Uri.";
        }
        
        public override bool IsValid(object value)
        {
            Uri uri = value as Uri;
            if (uri == null)
            {
                var s = value as string;
                if (s != null)
                {
                    if (!Uri.TryCreate(s, UriKind.Absolute, out uri))
                    {
                        return false;
                    }
                }
                else
                {
                    throw new Exception("AbsoluteUriAttribute applied to a value that is not a Uri or a string.");
                }
            }
            return uri.IsAbsoluteUri;
        }
    }
}<commit_msg>bug on null value<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Thinktecture.IdentityServer
{
    public class AbsoluteUriAttribute : ValidationAttribute
    {
        public AbsoluteUriAttribute()
        {
            ErrorMessage = "{0} must be an absolute Uri.";
        }
        
        public override bool IsValid(object value)
        {
            if (value == null) return true;

            Uri uri = value as Uri;
            if (uri == null)
            {
                var s = value as string;
                if (s != null)
                {
                    if (!Uri.TryCreate(s, UriKind.Absolute, out uri))
                    {
                        return false;
                    }
                }
                else
                {
                    throw new Exception("AbsoluteUriAttribute applied to a value that is not a Uri or a string.");
                }
            }
            return uri.IsAbsoluteUri;
        }
    }
}
{'fraction_non_alphanumeric': 0.07310344827586207, 'fraction_numerical': 0.0009195402298850574, 'mean_word_length': 1.2785340314136127, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2277893', 'n_tokens_mistral': 540, 'n_tokens_neox': 503, 'n_words': 154}