<commit_before>﻿using Microsoft.Ajax.Utilities;
using RequestReduce.Reducer;
using System;
using System.Security.AccessControl;
using RequestReduce.ResourceTypes;

namespace RequestReduce.Utilities
{
    public class Minifier : IMinifier
    {
        private Microsoft.Ajax.Utilities.Minifier minifier = new Microsoft.Ajax.Utilities.Minifier();

        public string Minify<T>(string unMinifiedContent) where T : IResourceType
        {
            if(typeof(T) == typeof(CssResource))
                return minifier.MinifyStyleSheet(unMinifiedContent);
            if(typeof(T) == typeof(JavaScriptResource))
                return minifier.MinifyJavaScript(unMinifiedContent);

            throw new ArgumentException("Cannot Minify Resources of unknown type", "resourceType");
        }

    }
}<commit_msg>make evals safe. less minified but wont break people.<commit_after>﻿using Microsoft.Ajax.Utilities;
using RequestReduce.Reducer;
using System;
using System.Security.AccessControl;
using RequestReduce.ResourceTypes;

namespace RequestReduce.Utilities
{
    public class Minifier : IMinifier
    {
        private Microsoft.Ajax.Utilities.Minifier minifier = new Microsoft.Ajax.Utilities.Minifier();
        private CodeSettings settings = new CodeSettings(){EvalTreatment = EvalTreatment.MakeAllSafe};

        public string Minify<T>(string unMinifiedContent) where T : IResourceType
        {
            if(typeof(T) == typeof(CssResource))
                return minifier.MinifyStyleSheet(unMinifiedContent);
            if(typeof(T) == typeof(JavaScriptResource))
                return minifier.MinifyJavaScript(unMinifiedContent, settings);

            throw new ArgumentException("Cannot Minify Resources of unknown type", "resourceType");
        }

    }
}
{'fraction_non_alphanumeric': 0.08487914558740865, 'fraction_numerical': 0.0, 'mean_word_length': 3.438902743142145, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5197749', 'n_tokens_mistral': 472, 'n_tokens_neox': 457, 'n_words': 105}