<commit_before>require 'net/http'
require 'uri'
require 'action_controller'
require 'ventilation/deep_stack'

module Ventilation
  module EsiHelper

    # Render resource on the edge
    def esi(resource, options = {})
      env = ENV['RAILS_ENV']

      # If we were passed a url...
      if resource =~ /^(http:\/\/)?[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu)[a-zA-Z0-9\-\.\/]+$/i
        # ...fetch and render an external resource...
        case env
        when 'production'
          %%<esi:include src="#{resource}" />%
        else
          url = URI.parse(resource)
          res = Net::HTTP.start(url.host, url.port) {|http|
            http.get(url.path)
          }
          res.body
        end
      else
        # ...otherwise render as an action.
        case env
        when 'production'
          %%<esi:include src="#{url_for url_options.merge(:action => resource)}" />%
        else<commit_msg>Fix a bug where url is not recognized.<commit_after>require 'net/http'
require 'uri'
require 'action_controller'
require 'ventilation/deep_stack'

module Ventilation
  module EsiHelper

    # Render resource on the edge
    def esi(resource, options = {})
      env = ENV['RAILS_ENV']

      # If we were passed a url...
      if resource =~ /^(http:\/\/)?[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu)[a-zA-Z0-9\-\.\/]*$/i
        # ...fetch and render an external resource...
        case env
        when 'production'
          %%<esi:include src="#{resource}" />%
        else
          url = URI.parse(resource)
          res = Net::HTTP.start(url.host, url.port) {|http|
            http.get(url.path)
          }
          res.body
        end
      else
        # ...otherwise render as an action.
        case env
        when 'production'
          %%<esi:include src="#{url_for url_options.merge(:action => resource)}" />%
        else
{'fraction_non_alphanumeric': 0.1548839719373988, 'fraction_numerical': 0.004317323259579061, 'mean_word_length': 1.9381933438985737, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '3601490', 'n_tokens_mistral': 594, 'n_tokens_neox': 579, 'n_words': 142}