<commit_before>var assert          = require('assert')
  , vows            = require('vows')
  , RequestHandler  = require('../lib/request-handler')

vows.describe('RequestHandler').addBatch({

  'getImageProcessUrlMatch': {
    'without namespacing': {
      topic: function() { return new RequestHandler({}) },
      'returns a match array for valid urls': function(i) {
        assert.ok(i.getImageProcessUrlMatch({ originalUrl: "/resize/123/foo.jpg" }) != null)
      },
      'returns no match array for invalid urls': function(i) {
        assert.ok(i.getImageProcessUrlMatch({ originalUrl: "/foo/123/foo.jpg" }) == null)
      },
    },

    'with namespacing': {
      topic: function() { return new RequestHandler({namespace: 'foo'}) },
      'with namespacing': {
        'returns a match array for valid urls': function(i) {
          assert.ok(i.getImageProcessUrlMatch({ originalUrl: "/foo/resize/123/foo.jpg" }) != null)
        },
        'returns no match array for invalid urls': function(i) {
          assert.ok(i.getImageProcessUrlMatch({ originalUrl: "/foo/bar/123/foo.jpg" }) == null)
        }
      }
    }
  },

  'isImageProcessUrl': {
    'without namespacing': {
      topic: function() { return new RequestHandler({}) },
      'returns a match array for valid urls': function(i) {
        assert.ok(i.isImageProcessUrl({ originalUrl: "/resize/123/foo.jpg" }))
      },
      'returns no match array for invalid urls': function(i) {
        assert.ok(i.isImageProcessUrl({ originalUrl: "/foo/123/foo.jpg" }) == false)
      }
    },

    'with namespacing': {
      topic: function() { return new RequestHandler({namespace: 'foo'}) },
      'returns a match array for valid urls': function(i) {
        assert.ok(i.isImageProcessUrl({ originalUrl: "/foo/resize/123/foo.jpg" }))
      },
      'returns no match array for invalid urls': function(i) {
        assert.ok(i.isImageProcessUrl({ originalUrl: "/foo/bar/123/foo.jpg" }) == false)
      }
    },
  },

  'getImageProcessUrlRegExp': {
    'without namespacing': {
      topic: function(){ return new RequestHandler({}) },
      'returns the default url match regexp': function(i) {
        assert.equal(i.getImageProcessUrlRegExp(), "/^/(resize|crop|fit)(/([^/?]+))?/")
      }
    },

    'with namespacing': {
      topic: function(){ return new RequestHandler({namespace: 'foo'}) },
      'returns namespaced url match regexp': function(i) {
        assert.equal(i.getImageProcessUrlRegExp(), "/^/foo/(resize|crop|fit)(/([^/?]+))?/")
      }
    }
  },

  'isImageSourceHostAllowed': {
    'with allowedHosts': {
      topic: function(){<commit_msg>added identify to tests<commit_after>var assert          = require('assert')
  , vows            = require('vows')
  , RequestHandler  = require('../lib/request-handler')

vows.describe('RequestHandler').addBatch({

  'getImageProcessUrlMatch': {
    'without namespacing': {
      topic: function() { return new RequestHandler({}) },
      'returns a match array for valid urls': function(i) {
        assert.ok(i.getImageProcessUrlMatch({ originalUrl: "/resize/123/foo.jpg" }) != null)
      },
      'returns no match array for invalid urls': function(i) {
        assert.ok(i.getImageProcessUrlMatch({ originalUrl: "/foo/123/foo.jpg" }) == null)
      },
    },

    'with namespacing': {
      topic: function() { return new RequestHandler({namespace: 'foo'}) },
      'with namespacing': {
        'returns a match array for valid urls': function(i) {
          assert.ok(i.getImageProcessUrlMatch({ originalUrl: "/foo/resize/123/foo.jpg" }) != null)
        },
        'returns no match array for invalid urls': function(i) {
          assert.ok(i.getImageProcessUrlMatch({ originalUrl: "/foo/bar/123/foo.jpg" }) == null)
        }
      }
    }
  },

  'isImageProcessUrl': {
    'without namespacing': {
      topic: function() { return new RequestHandler({}) },
      'returns a match array for valid urls': function(i) {
        assert.ok(i.isImageProcessUrl({ originalUrl: "/resize/123/foo.jpg" }))
      },
      'returns no match array for invalid urls': function(i) {
        assert.ok(i.isImageProcessUrl({ originalUrl: "/foo/123/foo.jpg" }) == false)
      }
    },

    'with namespacing': {
      topic: function() { return new RequestHandler({namespace: 'foo'}) },
      'returns a match array for valid urls': function(i) {
        assert.ok(i.isImageProcessUrl({ originalUrl: "/foo/resize/123/foo.jpg" }))
      },
      'returns no match array for invalid urls': function(i) {
        assert.ok(i.isImageProcessUrl({ originalUrl: "/foo/bar/123/foo.jpg" }) == false)
      }
    },
  },

  'getImageProcessUrlRegExp': {
    'without namespacing': {
      topic: function(){ return new RequestHandler({}) },
      'returns the default url match regexp': function(i) {
        assert.equal(i.getImageProcessUrlRegExp(), "/^/(identify|resize|crop|fit)(/([^/?]+))?/")
      }
    },

    'with namespacing': {
      topic: function(){ return new RequestHandler({namespace: 'foo'}) },
      'returns namespaced url match regexp': function(i) {
        assert.equal(i.getImageProcessUrlRegExp(), "/^/foo/(identify|resize|crop|fit)(/([^/?]+))?/")
      }
    }
  },

  'isImageSourceHostAllowed': {
    'with allowedHosts': {
      topic: function(){
{'fraction_non_alphanumeric': 0.16672953602414184, 'fraction_numerical': 0.009053187476423991, 'mean_word_length': 2.870802919708029, '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': '7561874', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1641, 'n_words': 350}